您的发行版应提供一个名为的实用程序
pdftotext:
find /path -name '*.pdf' -exec sh -c 'pdftotext "{}" - | grep --with-filename --label="{}" --color "your pattern"' ;要使pdftotext输出到stdout,而不是文件,必须使用“-”。在
--with-filename和
--label=选项将在grep的输出把文件名。可选
--color标志不错,它告诉grep使用终端上的颜色进行输出。
(在Ubuntu中,
pdftotext由
xpdf-utils或提供
poppler-utils。)
这种方法,使用
pdftotext和
grep,拥有一个优势
pdfgrep,如果你想使用GNU的特点
grep是
pdfgrep不支持。
注意 :pdfgrep-1.3.x支持
-C打印上下文行的选项。



