grep,但只有某些文件扩展名 [英] Grep, but only certain file extensions
本文介绍了grep,但只有某些文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一些脚本到Grep某些目录,但这些目录包含所有类型的文件类型。
I am working on writing some scripts to Grep certain directories, but these directories contain all sorts of file types.
我想grep只是 .h
和 .cpp
,但未来可能还有其他几个。
I want to grep just .h
and .cpp
for now, but maybe a few others in the future.
到目前为止,我有:
{ 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
任何人都可以告诉我如何添加只是特定的文件扩展?
Can anyone show me how I would now add just specific file extensions?
推荐答案
只需使用 - include
参数, :
grep -r -i --include \*.h --include \*.cpp CP_Image ~/path[12345] | mailx -s GREP email@domain.com
这应该可以做你想要的。
that should do what you want.
这篇关于grep,但只有某些文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文