我想从我的 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 ×1