我已经熟悉了
例如,如果目录结构如下:
grep -r "searchTerm" .
,也熟悉了 grep -r "searchTerm" exclude={subdir1, subdir2} .
但是,我正在寻找一种递归搜索的方法,可以在子目录中搜索并忽略某些子目录的子目录。例如,如果目录结构如下:
/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
及其所有子目录吗? - iamauseridc
和otherStuffIdc
。 - Stevegrep -r pattern --exclude-dir=idc
,这个没用吗? - iamauser