How do I find files that do not contain a given string pattern?

Senthil Kumar picture Senthil Kumar · Nov 17, 2009 · Viewed 283.1k times · Source

How do I find out the files in the current directory which do not contain the word foo (using grep)?

Answer

ghostdog74 picture ghostdog74 · Nov 17, 2009

If your grep has the -L (or --files-without-match) option:

$ grep -L "foo" *