0

On occasion I need to search for a specific string within several files, but the results are only relevant if those files contain a second specific string, not necessarily on the same line as that first specific string.

1 Answer 1

1

grep -ril 'string 1' * | xargs grep -rin 'string 2'

The -l includes only file names rather than the matching lines themselves. The xargs reads the files to search from the standard output of the first grep.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .