2009-04-08, 12:18 PM
2009-04-08, 12:37 PM
there is --exclude=foobar which would skip a file named foobar. not sure if it would skip a directory of that name too.
for recursing directories the 'find' command offers much more options that let you specify conditions, and you can use 'find -print0 | xargs -0 grep' to pass the list of files found by find on to grep.
some people also do it with grep ... | grep -v ... but that is not a reliable method.
for recursing directories the 'find' command offers much more options that let you specify conditions, and you can use 'find -print0 | xargs -0 grep' to pass the list of files found by find on to grep.
some people also do it with grep ... | grep -v ... but that is not a reliable method.
2009-04-08, 01:09 PM
So if I wanted to find all of the .html and .php files in my /home/ directory except for 2 directories and then have grep search those files how would I could about that?
2009-04-08, 01:27 PM
find "/home/" -path "/home/dir1" -prune -path "/home/dir2" -prune -name "*.html" -or -name "*.php" -print0 | xargs -0 grep foobar