12

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
  • 1,027
  • 3
  • 15
  • 26

2 Answers2

25

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,916
  • 3
  • 51
  • 70
9

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

find /Users/me/PDFFiles/  -type f -name "*.pdf" -exec grep -HL 'Font' '{}' ';'
Slinky
  • 1,027
  • 3
  • 15
  • 26