How can I find all files in a directory recursively, except those in the .git
directory?
I tried the folowing: find . \! -name ".*"
but that didn't work.
Try:
find . -name '.git' -prune -o -print
-prune
as an action will cause the matched directories to be "pruned" from the search tree, i.e. they won't be searched.
-o
is the POSIX-compliant of -or
(the logical or). So basically, find is looking for something named .git, but prune it, or anything else, and then print it. -print
is the default expression that is normally omitted from typical find calls. @scrrr