shell script: recursively find a file with a keyword
How to find all files with a specific key word in a directory with subdirectories. For example, given a directory r_dir and subdirectoris d1, and d2, I need find all files contains "key_word" under r_dir and d1 and d2开发者_开发百科.
On Windows:
findstr /spin /c:"key_word" *.*
(s = recursive, p = ignore binaries, i = case-insensitive, n = line numbers)
On linux / OS X:
grep -i -r key_word *
(i = case-insensitive, r = recurse subdirs)
I use something like:
find r_dir -type f -exec grep "key_word" {} \; -print
精彩评论