How should I glob for all hidden files?
GLOBIGNORE=".:.."
to hide the . and .. directories. This also sets the dotglob
option: *
matches both hidden and non-hidden files.
You can also do
shopt -s dotglob
Gilles :)
You can use the following extglob
pattern:
.@(!(.|))
.
matches a literal.
at first@()
is aextglob
pattern, will match one of the patterns inside, as we have only one pattern inside it, it will pick that!(.|)
is anotherextglob
pattern (nested), which matches any file with no or one.
; As we have matched.
at start already, this whole pattern will match all files starting with.
except.
and..
.
extglob
is enabled on interactive sessions of bash
by default in Ubuntu. If not, enable it first:
shopt -s extglob
Example:
$ echo .@(!(.|))
.bar .foo .spam
You can use a find
command here. For example something like
find -type f -name ".*" -exec chmod 775 {} \;
This will find hidden files and change permissions
Edit to include the comment by @gerrit:
find -type f -maxdepth 1 -name ".*" -exec chmod 775 {} \;
This will limit the search top the current directory instead of searching recursively.