grep all files and sub-directories in a directory for a string
Linux October 14th, 2005This is mostly just a post for my recollection. To search all files and subdirectories recursively for a phrase:
grep -r -i somethingtosearchfor ./
This is mostly just a post for my recollection. To search all files and subdirectories recursively for a phrase:
grep -r -i somethingtosearchfor ./
October 25th, 2005 at 1:36 pm
Tony, what’s the difference between -i and -name? I have used the -name switch a lot with success, as in:
grep ./ -name foo
October 25th, 2005 at 8:26 pm
Hey Scott,
I’m not sure what the difference is. I only pulled this trick out my little reference book.
November 9th, 2005 at 8:29 am
-i means ignorecase
March 11th, 2008 at 11:18 am
Guys,
Not all Unixes have a “grep” that supports the “-r” option.
This command is little longer but will work on any unix:
find top-dir -exec grep whatever /dev/null {} \;