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

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted
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.
link|improve this answer
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
feedback
find some/dir ... \( -exec grep -q 'FOO' {} \; -o -print \)
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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