小编Jak*_*ake的帖子

使用 grep 排除嵌套目录

我想从我的 grep 搜索中排除嵌套目录,例如/path/to/file. 例如:

jake@jake-laptop:~/test$ egrep -r --exclude-dir="path" "hello" .
jake@jake-laptop:~/test$ egrep -r --exclude-dir="to" "hello" .
jake@jake-laptop:~/test$ egrep -r --exclude-dir="file" "hello" .
jake@jake-laptop:~/test$ egrep -r --exclude-dir="path/to/file" "hello" .
./path/to/file/f.txt:hello
Run Code Online (Sandbox Code Playgroud)

在最后一行中,文件没有被排除,显然是因为我有多个嵌套目录提供了exclude-dir参数。如何获得最后一个示例以排除path/to/file目录中的搜索?

grep

6
推荐指数
1
解决办法
1594
查看次数

标签 统计

grep ×1