1

So I'm using this

grep -lrai "search query" /right/here/

to search for a word in 100+ pdf files (which is why I have included -a).

Using grep shows 3 results, whereas a simple search in Spotlight will show a lot more in the same directory.

Am i doing something wrong here?

Jose187
  • 449
  • 1
  • 7
  • 15

1 Answers1

2

Using "-a" option does not magically convert PDF documents into plain text documents, unfortunately. If you need to grep search, you have to convert PDFs to text documents first (i.e. use this recipe: http://www.ehow.com/how_4794405_convert-pdf-word-document-mac.html).

Kuba Wyrostek
  • 6,163
  • 1
  • 22
  • 40
  • 3
    +1. But it's worth explaining that the reason Spotlight can find the text is because it has a PDF importer built in, so it can index text within PDF documents. – abarnert Jul 20 '12 at 21:52
  • Also in general Spotlight does not index every directory - though that's obviously not the case in this particular scenario it's something to keep in mind.. – Jay Sep 30 '12 at 07:22