Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a command that finds all the PDF files that contain the string "Font"

find /Users/me/PDFFiles/  -type f -name "*.pdf" -exec grep -H 'Font' '{}' ';'

How can I change this command such that it does the inverse? Finds all PDF files that do not contain the search string "Font"


share|improve this question
grep -v seems to be fairly simple, have you tried it? – NickW May 15 '13 at 15:26
Thanks. No I did not try that. I found the grep "L" flag which does what I needed. – Slinky May 15 '13 at 15:29
I don't think the "-v" option is going to do what you want, anyway, as it will output non-matching lines. – cjc May 15 '13 at 15:30
Yeah, mixed up exclude and invert, I did. – NickW May 15 '13 at 15:32
up vote 8 down vote accepted

You want to use the "-L" option of grep:

 -L, --files-without-match
         Only the names of files not containing selected lines are written to standard output.  Path-
         names are listed once per file searched.  If the standard input is searched, the string
         ``(standard input)'' is written.
share|improve this answer

Just add the "L" flag. This does the inverse

find /Users/me/PDFFiles/  -type f -name "*.pdf" -exec grep -HL 'Font' '{}' ';'
share|improve this answer

Your Answer


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.