I have a set of files that contain some information.
I am interested in the subset of files that do not contain a specific pattern at all.

cat file.txt  
trivial information
some customer data   

let’s say that I am interested in files that do not have the line ‘trivial information’.
How would I do that?
If I do:

grep -v ‘trivial information’   

it will not work because the rest of the lines in the file are match to this inverted search so the file.txt will end up in the result.
So how do I do an invert match on the whole file and not line by line?


1 Answer 1


You are looking for the -L flag:

grep -L 'trivial information' *

From man grep:

-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.

  • 2
    I wish I remembered that switch in the future, I've done for f in ... grep $p $f >/dev/null || echo $f a couple of times...
    – ilkkachu
    Commented Apr 14, 2017 at 13:03

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