0

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.

1 Answer 1

2

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.

2
  • -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
    – slhck
    Commented Feb 27, 2012 at 18:45
  • @slhck: Didn't know that. Thanks!
    – scrrr
    Commented Feb 27, 2012 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .