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
在Linux的终端中,搜索当前目录和子目录中含有某关键字的文件,命令如下:
- 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 {} \;
Linux中find命令用法全汇总,看完就没有不会用的!
WIN 搜索神器 EveryThing