I want to search for a specific keyword in a pdf file using linux shell. How I will use the grep command to do that?
Searching a keyword in a pdf file
linux;shell;shell script;terminal
You won't. PDF is a binary format so you need to convert to text first. Grep can search through the data but there's no reason to assume that a PDF that, when opened in a PDF viewer, has the string foo will actually contain foo in the original, binary data. It may be written very differently in the source. A simple solution is to install pdftotext and use that. It should be available in your distribution's repositories. On Debian-based systems, you can install it with:sudo apt-get install poppler-utilsThen, you can search through your PDF file with:pdftotext foo.pdf - | grep keyword