[英]How to grep recursively and ignore subdirectories of subdirectories?
I am already familiar with grep -r "searchTerm" .
我已经熟悉
grep -r "searchTerm" .
and I am familiar with grep -r "searchTerm" exclude={subdir1, subdir2} .
我熟悉
grep -r "searchTerm" exclude={subdir1, subdir2} .
However, I am looking for a way to grep recursively, through subdirectories and ignore certain subdirectories of subdirectories.但是,我正在寻找一种通过子目录递归 grep 并忽略子目录的某些子目录的方法。
For example, if the directory structure is as follows:例如,如果目录结构如下:
/folder
/subdir1
/idc/file.js
/files/file.js
/otherStuffIdc/file.js
/subdir2
/idc/file2.js
/files/file2.js
/otherStuffIdc/file2.js
...
How would I be able to exclude idc and otherStuffIdc, since these folders are subdirectories of subdirectories of the root directory I am beginning my search in?我如何能够排除 idc 和 otherStuffIdc,因为这些文件夹是我开始搜索的根目录的子目录的子目录?
My example is simplified but in my real world issue, there are many, many subDir#
so it is not feasible for me to just grep each individual subdirectory.我的例子被简化了,但在我的现实世界问题中,有很多很多
subDir#
所以我只对每个单独的子目录进行 grep 是不可行的。
这将排除名称为idc
和otherStuffIdc
的(子)目录。
grep -r pattern --exclude-dir=idc,otherStuffIdc
对我来说,这只适用于(子)文件夹周围的花括号
grep -r pattern --exclude-dir={idc,otherStuffIdc}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.