Kasramvd Kasramvd - 6 months ago 26
Bash Question

search a word inside a pdf in terminal linux without any app

Is it possible to use

or other command and/or
in order to search for a particular pattern within a PDF file?


If you have the pdftotext utility installed, you can use the following command to search through the text of a PDF file:

pdftotext myfile.pdf - | grep 'pattern'

You have to use some utility (such as pdftotext) to convert the PDF file to text before feeding it into grep (otherwise grep would have a hard time making sense out of the raw PDF file), but any utility that does this should work.

On Ubuntu and Debian, pdftotext is part of the poppler-utils package.