我正在执行这样的嵌套 grep:
grep -ir "Some string" . |grep "Another string I want to find in the other grep's results"
Run Code Online (Sandbox Code Playgroud)
这完全按预期工作(我也从第二个 grep 过滤的第一个 grep 中获得了结果),但是一旦我添加了一个“-l”选项,所以我只能从第二个 grep 中获取文件列表,我不什么都得不到。
grep -ir "Some string" . |grep -l "Another string I want to find in the other grep's results"
Run Code Online (Sandbox Code Playgroud)
这导致以下输出:
(标准输出)
我想当我只想要文件列表时管道不起作用。任何替代方案?