If I want to see a list of files which contain the word 'FOO' I can use

fgrep -l 'FOO' *

but what if I want to see all of the files which do not contain the word FOO?

I can't use

fgrep -vl 'FOO' *

because that will show me every file (unless there's a file which only) contains the word 'FOO'.

(It seems like I knew of a way to do this, but now I can't remember it.)

fgrep -L 'FOO' *

It's in 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.
  • I swear I checked the man page about 5 times and kept missing it. (is there a nearsighted "badge" :-? Thanks for the cluestick! – TJ Luoma Aug 7 '11 at 21:10
find some/dir ... \( -exec grep -q 'FOO' {} \; -o -print \)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.