grep all files and sub-directories in a directory for a string
This is mostly just a post for my recollection. To search all files and subdirectories recursively for a phrase:
grep -r -i somethingtosearchfor ./
Categories: Linux
This is mostly just a post for my recollection. To search all files and subdirectories recursively for a phrase:
grep -r -i somethingtosearchfor ./
Tony, what’s the difference between -i and -name? I have used the -name switch a lot with success, as in:
grep ./ -name foo
Hey Scott,
I’m not sure what the difference is. I only pulled this trick out my little reference book.
-i means ignorecase
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 {} \;