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.
-v means "invert the match" in grep, in other words, return all non matching lines.
To search multiple files with the grep command, insert the filenames you want to search, separated with a space character. The terminal prints the name of every file that contains the matching lines, and the actual lines that include the required string of characters. You can append as many filenames as needed.
grep -l firstmatch * | xargs grep secondmatch {}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With