How do I recursively view a list of files that has one string and specifically doesn't have another string? Also, I mean to evaluate the text of the files, not the filenames.
Conclusion:
As per comments, I ended up using:
find . -name "*.html" -exec grep -lR 'base\-maps' {} \; | xargs grep -L 'base\-maps\-bot'
This returned files with "base-maps" and not "base-maps-bot". Thank you!!
Best Answer
Try this:
Explanation:
grep -lr
makes grep recursively (r) output a list (l) of all files that contain<string-to-match>
. xargs loops over these files, callinggrep -L
on each one of them.grep -L
will only output the filename when the file does not contain<string-not-to-match>
.