I have a lots of files with multiple lines, and in most case, one of the lines contain a certain pattern. I would like to list every file that does not have a line with this pattern.
Use the "-L" option in order to have file WITHOUT the pattern. Per the man page:
-L, --files-without-match
Suppress normal output; instead print the name of each input file from which no output would normally have been printed. The scanning will stop on the first match.
Grep returns 0/1 to indicate if there was a match, so you can do something like this:
for f in *.txt; do if ! grep -q "some expression" $f; then echo $f fi done
EDIT: You can also use the -L option:
grep -L "some expression" *
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