NSA
NSA

Reputation: 6027

How do I pass the resulting files from one grep pass to another so that I only grep through the subset with the second pass?

I want to be able to take the files I found with my first grep statement, something like this for example: grep -r Makefile * And then pass the files found in that pass of grep to a second grep with something like this for example: grep {files} '-lfoo'

How do I do this? I know there must be a way.

Thank you.

Upvotes: 5

Views: 3216

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798804

grep -l firstmatch * | xargs grep secondmatch {}

Upvotes: 7

Related Questions