查找包含给定文本的文件 [英] Find files containing a given text
本文介绍了查找包含给定文本的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在bash中,我想为每个类型为.php|.html|.js
的文件返回文件名(以及文件的路径),该文件包含不区分大小写的字符串"document.cookie" | "setcookie"
In bash I want to return file name (and the path to the file) for every file of type .php|.html|.js
containing the case-insensitive string "document.cookie" | "setcookie"
我该怎么做?
推荐答案
egrep -ir --include=*.{php,html,js} "(document.cookie|setcookie)" .
r
标志意味着递归搜索(搜索子目录). i
标志表示不区分大小写.
The r
flag means to search recursively (search subdirectories). The i
flag means case insensitive.
如果只想添加文件名,请添加l
(小写的L
)标志:
If you just want file names add the l
(lowercase L
) flag:
egrep -lir --include=*.{php,html,js} "(document.cookie|setcookie)" .
这篇关于查找包含给定文本的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文