foo我想在目录中搜索一个字符串app,但不包括文件名中包含migrations的任何文件。我希望这个grep命令能够工作
grep -Ir --include "*.py" --exclude "*migrations*" foo app/
上面的命令似乎忽略了--exclude过滤器。作为替代方案,我可以做
grep -Ir --include "*.py" foo app/ | grep -v migrations
这行得通,但这会foo在结果中失去突出显示。我也可以find加入其中并保持突出显示。
find app/ -name "*.py" -print0 | xargs -0 grep --exclude "*migrations*" foo
我只是想知道我是否遗漏了有关将命令行参数组合到 grep 的内容,或者它们是否根本不能一起工作。