Red*_*ick 18
grep -l string2 `grep -l string1 /path/*`
Run Code Online (Sandbox Code Playgroud)
这与
grep -l string2 $(grep -l string1 /path/*)
Run Code Online (Sandbox Code Playgroud)
编辑:这就是为什么grep string1 /path/* | grep string2不做我认为 alwbtc 想要的。
$ cd /tmp
$ cat a
apples
oranges
bananas
$ cat b
apples
mangoes
lemons
$ cat c
mangoes
limes
pears
$ cd ~
$ grep apples /tmp/* | grep mangoes
$
Run Code Online (Sandbox Code Playgroud)
未找到任何内容,但文件 b 包含两个字符串。
这就是我认为 alwbtc 想要的
$ grep -l apples $(grep -l mangoes /tmp/*)
/tmp/b
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18822 次 |
| 最近记录: |