Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know this is teeball for veteran sysadmins, but I'm looking to search a directory tree for file contents that match a regex (here, the word "Keyword"). I've gotten that far, but now I'm having trouble ignoring files in a hidden (.svn) file tree.

Here's what I'm working with. You can see that I am fine searching for files that include ".svn" in the name but I can't seem to invert the iname var with a ! as I've see in other docs.

find . -exec grep "Keyword" '{}' \; -iname .svn; -print

The above returns pretty much anything and everything.

share|improve this question
up vote 0 down vote accepted
find . \( -iname '.svn' -prune \) -o \( -exec grep -q ... \; -print \)
share|improve this answer

How about recursive grep:

grep -r --exclude "*.svn*" "Keyword" .
share|improve this answer

Your Answer


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.