适用场景
在 PDF 文件中搜索文本。 本条为命令参考与排查示例;请先确认命令已安装,再按示例定位实际参数和输出。
pdfgrep
在 PDF 文件中搜索文本。 更多信息:https://pdfgrep.org/doc.html。
- 在 PDF 中查找与关键词匹配的行:
pdfgrep {{关键词}} {{文件.pdf}}
- 包含每个匹配行的文件名和页码:
pdfgrep {{[-H|--with-filename]}} {{[-n|--page-number]}} {{关键词}} {{文件.pdf}}
- 对以 "foo" 开头关键词搜索,返回前 3 个匹配项,不区分大小写:
pdfgrep {{[-m|--max-count]}} {{3}} {{[-i|--ignore-case]}} '{{^foo}}' {{文件.pdf}}
- 在当前目录中扩展名为.pdf 的文件中递归查找关键词:
pdfgrep {{[-r|--recursive]}} {{关键词}}
- 在与当前目录中特定文件名 "*book.pdf" 匹配的文件上递归查找关键词:
pdfgrep {{[-r|--recursive]}} --include '{{*book.pdf}}' {{关键词}}