Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

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.
share|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
add comment
find some/dir ... \( -exec grep -q 'FOO' {} \; -o -print \)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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