brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: pdfgrep searches a whole folder of PDF files for a phrase

Search
~/tips/tip-pdfgrep-folder-phrase

pdfgrep -rin "warranty" ~/Documents

Find the right manual or invoice by what is written in it.

A folder full of manuals and invoices with names like scan_0042.pdf is no help when I want the one that mentions a warranty. Plain grep cannot read the text inside a PDF, but this tool can.

Install it from your package manager (apt install pdfgrep or brew install pdfgrep), then:

pdfgrep -rin "warranty" ~/Documents

-r walks through the folder and its subfolders, -i ignores case and -n shows the page number of each match, so you can open the file and jump straight there. To get a count per file instead:

pdfgrep -ric "warranty" ~/Documents

The usual regular expressions work.

The big limit is scans. A PDF that is only a picture of a page has no text to search, and it silently gives no match. Add --warn-empty to be told which files have no searchable text, then run those through OCR if they matter. A phrase broken across two lines in the layout can be missed too, so try one distinctive word. For password protected files there is --password, but be aware that it ends up in your shell history.

Further reading: pdfgrep manual

Going deeper: Run degoog on Unraid as your own search page, compared with SearXNG and 4get

More Search tips !!wfr Wau Holland zipgrep db_host backup.zip "fatal error" repo:github-linguist/linguist is:open involves:@me The <search> element replaces role="search" on a form All Search tips (11) All topics

Link