我不知道这是否可行,或者 grep 是不是错误的工具,或者是什么,但我想做的是:
grep -rsI "some_string" *.c
然后将找到结果的文件列表通过管道传输到第二个 grep 中:
grep -rsI "second_string" <list of files from first grep>
我知道我可以通过管道将确切的行传递给第二个 grep:
grep -rsI "some_string" *.c | grep "second_string"
但这不是我正在寻找的不是,我不想只搜索以前命中的行,而是搜索这些行所在的整个文件。这可能吗?有什么想法吗?
最佳答案
grep -rsIl "some_string" *.c | xargs grep -sI "second_string"
关于linux - grep'ing 从以前的 grep 输出的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12465867/