3

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

2 Answers 2

3
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.
1
  • 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, 2011 at 21:10
2
find some/dir ... \( -exec grep -q 'FOO' {} \; -o -print \)

You must log in to answer this question.

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