I'm using the following script to make all files in a directory hidden by adding a dot "." at the beginning.
GLOBIGNORE=".:.."
for file in *; do
mv -n "$file" ".$file";
done
How can I exclude the already hidden files?
Thanks for your help!
The wildcard already doesn't match any hidden files, unless you have separately enabled dotglob
.
If you have configured dotglob
to include hidden files, you can momentarily turn it off with
shopt -u dotglob
Using GLOBIGNORE
enables dotglob
so maybe the simplest fix is to take that out. You could also change it to
GLOBIGNORE='.*'
but this is effectively the same as unsetting it.