Match all files under all nested directories with shell globbing
Specifically about git (gitignore, gitattributes, and commands that take filenames): if the pattern contains no slash, *
wildcards will match deep. If it does contain a slash, git will call fnmatch with the FNM_PATHNAME
flag, and simple wildcards won't match slashes. **
to match deep isn't supported. Maybe this kind of deep matching could be more widely supported with a new FNM_STARSTAR
flag, and an implementation in glibc, gnulib and other places.
If you want to act on all the files returned by find, rather than just list them, you can pipe them to xargs:
find <directory> -type f | xargs ls
But this is only for commands that don't have a recursive flag.
In Bash 4, with shopt -s globstar
, and zsh you can use **/*
which will include everything except hidden files. You can do shopt -s dotglob
in Bash 4 or setopt dotglob
in zsh to cause hidden files to be included.
In ksh, set -o globstar
enables it. I don't think there's a way to include dot files implicitly, but I think **/{.[^.],}*
works.