小编OMA*_*OMA的帖子

嵌套的管道 grep 结果是一个字符串,上面写着“(标准输入)”

我正在执行这样的嵌套 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)

这导致以下输出:

(标准输出)

我想当我只想要文件列表时管道不起作用。任何替代方案?

grep pipe

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

标签 统计

grep ×1

pipe ×1