9

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"

7ochem
  • 280
  • 1
  • 3
  • 12
Slinky
  • 957
  • 3
  • 14
  • 25

2 Answers2

22

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.
cjc
  • 24,533
  • 2
  • 49
  • 69
8

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

find /Users/me/PDFFiles/  -type f -name "*.pdf" -exec grep -HL 'Font' '{}' ';'
Slinky
  • 957
  • 3
  • 14
  • 25