find和grep并用,进行全文搜索的用法
find / -type f -exec grep -l “IP” {} \;
why ?
find / -type f -> find all files starting from /
find …. -exec -> for each item found, do the following command. Where you normally place the filename in you command, put {} .
grep -l “IP” something -> returns the filename if string “IP” is found in file something
Hope this helps
Gert (引用此人2000年的帖子,谢谢)
找到一种更简洁的方法
grep -lr ‘string’ /etc/
这个命令就可以搞定。搜索etc下面的文件,包含所有目录下的文件。这样就搞定了。
-i,乎略大小写
-l,找出含有这个字符串的文件
-r,不放过子目录