您的发行版应该提供一个名为pdftotext
的实用程序:
find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' \;
要将pdftotext输出到stdout,而不是文件,则必须使用"-".
(在Ubuntu中,pdftotext
由软件包xpdf-utils
或poppler-utils
提供.)
如果你想使用GNUgrep
不支持的功能,这种使用pdftotext
和grep
的方法比pdfgrep
有优势.Note:pdfgrep-1.3.x支持打印上下文行的-C
选项.