linux下查找包含关键字的所有文件 find grep

11 年 ago jony linux下查找包含关键字的所有文件 find grep已关闭评论

在linux下如果要查找包含某个关键字的文件,如要在/root/目录下搜索带有关键字“www”的文件,在终端下运行命令:

find ./ -name *.txt    或者: find ./ -name "*.txt"   #从当前目录下查找所有的.txt文件

find /root/ –type f |xargs grep “www”

grep -r "test" /root/    或者 grep "baidu.com". -r     #从当前目录查找包含有XXX字符的文件

查找当前目录及其子目录下 所有php文件中包含某关键字.

find  -name '*.php' |xargs  grep -l 'keyword'  

在Linux的终端中,搜索当前目录和子目录中含有某关键字的文件,命令如下:
  1. grep ‘KeyWord’  ./ -Rn

查看包含有关键字的文件并删除之

find /var/www/html/test/ -type f -exec grep "dangci500.com" {} \; -print -exec rm {} \;

或者

find /var/www/htm/test/ 'abc123' -exec rm -f {} \;

https://fomore.net/os/?p=2234

快速的查找linux下的大文件

Linux中find命令用法全汇总,看完就没有不会用的!

WIN     搜索神器 EveryThing

grep、sed、awk高效文件处理3剑客

https://juejin.im/post/6845166891493785613