我如何递归grep,但只能在具有某些扩展名的文件中? [英] How can I grep recursively, but only in files with certain extensions?
本文介绍了我如何递归grep,但只能在具有某些扩展名的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为 grep
某些目录编写脚本:
I'm working on a script to grep
certain directories:
{ grep -r -i CP_Image ~/path1/;
grep -r -i CP_Image ~/path2/;
grep -r -i CP_Image ~/path3/;
grep -r -i CP_Image ~/path4/;
grep -r -i CP_Image ~/path5/; }
| mailx -s GREP email@domain.com
如何将结果仅限制为扩展名 .h
和 .cpp
?
How can I limit results only to extensions .h
and .cpp
?
推荐答案
只需使用-include
参数,如下所示:
Just use the --include
parameter, like this:
grep -inr --include \*.h --include \*.cpp CP_Image ~/path[12345] | mailx -s GREP email@domain.com
那应该做你想要的.
查看全文