Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
Thank you. Also for the explanation. –  scrrr Feb 27 '12 at 18:42
    
-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 Feb 27 '12 at 18:45
    
@slhck: Didn't know that. Thanks! –  scrrr Feb 27 '12 at 18:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.