Linux 如何递归grep并忽略子目录的子目录?
我已经熟悉了Linux 如何递归grep并忽略子目录的子目录?,linux,macos,recursion,grep,Linux,Macos,Recursion,Grep,我已经熟悉了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
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和其他StuffIDC
我的例子很简单,但在我的现实世界中,有很多子目录,所以我不可能只对每个子目录进行grep处理。这将排除名为idc
和otherStuffIdc
的(子)目录
grep -r pattern --exclude-dir=idc,otherStuffIdc
对我来说,这只适用于(子)文件夹周围的花括号
是否要从搜索中排除idc及其所有子目录?是!精确地我想排除
idc
和otherStuffIdc
grep-r模式--exclude dir=idc
,这不起作用吗?这起作用了,我一定是早些时候弄糟了。谢谢@iamauserOn那是什么操作系统?Ubuntu 18.04.:)我只是在没有带花括号的情况下又试了一次,但没有成功。。奇怪的
grep -r pattern --exclude-dir={idc,otherStuffIdc}