Finding files that do not have a particular line

4

The following command lists all files (with lines) that have the mentioned line:

$ grep  "\[oow\] running" *.log

However, what I want to know is all the *.log files that do not have that line. Using the -v option to grep prints innumerous number of other lines. But I only want the file that does not have the mentioned line. How does one normally do this in Unix/Mac (in command line of course)?

Sridhar Ratnakumar

Posted 2009-11-09T23:15:31.703

Reputation: 4 041

Answers

10

Use the -L option:

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

djhowell

Posted 2009-11-09T23:15:31.703

Reputation: 3 535

3

$ grep -L "\[oow\] running" *.log

Edward Anderson

Posted 2009-11-09T23:15:31.703

Reputation: 550