我已经熟悉grep -r "searchTerm" .
并且熟悉,grep -r "searchTerm" exclude={subdir1, subdir2} .
但是,我正在寻找一种通过子目录递归grep的方法,而忽略子目录的某些子目录。
例如,如果目录结构如下:
/folder
/subdir1
/idc/file.js
/files/file.js
/otherStuffIdc/file.js
/subdir2
/idc/file2.js
/files/file2.js
/otherStuffIdc/file2.js
...
由于这些文件夹是我要开始搜索的根目录的子目录的子目录,因此如何排除IDC和otherStuffIdc?
我的示例已简化,但是在我的现实世界中,有很多很多,subDir#
因此仅对每个单独的子目录进行grep都是不可行的。
这将排除名称为idc
和的(子)目录otherStuffIdc
。
grep -r pattern --exclude-dir=idc,otherStuffIdc
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句