I don’t know if this is possible, or if grep is the wrong tool, or what, but what I want to do is this:
grep -rsI "some_string" *.c
Then pipe the list of files where were results were found into a second grep:
grep -rsI "second_string" <list of files from first grep>
I know I can pipe the exact lines to a second grep via:
grep -rsI "some_string" *.c | grep "second_string"
but that’s not what I’m looking for, I don’t want to just search the lines where previous hits were, but the entire file those lines were in. Is that even possible? Any ideas?
1 Answer