我正在尝试找到保存在外部备份驱动器上的客户的 pdf 文件,其中包含超过 8000 个 pdf 文件和数百个文件夹。
例如,如果我想搜索驱动器 X: 上包含我的客户名称“Sequoia Group”的所有 pdf 文件,有哪些有用的命令行和/或工具来实现相关的输出结果?
我使用的是 MacOS High Sierra,带有 zsh,我还通过自制程序安装了 GNU grep、ack 和 pdfgrep。但是,我还没有找到该文件。
文件名未知,因为所有文件都保存为 PDF-Backup-0001、PDF-Backup-0002...等,
到目前为止,我使用了以下命令,但没有成功:
#grep -wirl "sequoia group" ./
#pdfgrep -iHncRZ "sequoia group"
#mdfind "sequoia group"
Run Code Online (Sandbox Code Playgroud)
另外,建议使用此命令行,但是,我不确定在哪里放置名称,因此我将 /path 替换为驱动器的路径,并将模式替换为“sequoia”,仍然没有找到任何匹配项
#find /path -iname '*.pdf' -exec pdfgrep pattern {} +
#find /Volumes/X Backup -iname '*.pdf' -exec pdfgrep "sequoia" {} +
Run Code Online (Sandbox Code Playgroud) 我在 pdf 文件中找到多行模式的页码,通过如何在 pdf 文件和文本文件中 grep 多行模式?以及 如何在 pdf 文件中搜索字符串,并找到该字符串出现的每个页面的物理页码?
$ pdfgrep -Pn '(?s)image\s+?not\s+?available' main_text.pdf
49: image
not
available
51: image
not
available
53: image
not
available
54: image
not
available
55: image
not
available
Run Code Online (Sandbox Code Playgroud)
我只想提取页码,但因为模式是多行的,我得到
$ pdfgrep -Pn '(?s)image\s+?not\s+?available' main_text.pdf | awk -F":" '{print $1}'
49
not
available
51
not
available
53
not
available
54
not
available
55
not
available
Run Code Online (Sandbox Code Playgroud)
代替
49
51
53
54
55
Run Code Online (Sandbox Code Playgroud)
我想知道如何仅提取页码,而不管模式是否为多行?谢谢。