0

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.

kmarsh
  • 3,103
  • 15
  • 22
editor
  • 373
  • 1
  • 5
  • 20

2 Answers2

1

How about recursive grep:

grep -r --exclude "*.svn*" "Keyword" .
Steve Baker
  • 111
  • 2
0
find . \( -iname '.svn' -prune \) -o \( -exec grep -q ... \; -print \)
Ignacio Vazquez-Abrams
  • 45,019
  • 5
  • 78
  • 84