Issue
I'd like to know if there is any way to check if there is a string inside a pdf
file using a shell script? I was looking for something like:
if [search(string,pdf_file)] > 0 then
echo "exist"
fi
Solution
As nicely pointed by Simon, you can simply convert the pdf
to plain text using pdftotext
, and then, just search for what you're looking for.
After conversion, you may use grep
, bash regex, or any variation you want:
while read line; do
if [[ ${line} =~ [0-9]{4}(-[0-9]{2}){2} ]]; then
echo ">>> Found date;";
fi
done < <(pdftotext infile.pdf -)
Answered By - Rubens Answer Checked By - Senaida (WPSolving Volunteer)