【问题标题】:Using pdfgrep to search for sentences containing specific words使用 pdfgrep 搜索包含特定单词的句子
【发布时间】:2018-11-30 22:03:01
【问题描述】:

对于我的统计考试,我希望能够在我们的教科书中搜索包含特定单词的句子(我们有一个 pdf 文件)。我已经下载了命令行工具 pdfgrep (grep for pdf files)

一个例子:

我想搜索一个包含“中位数”和“指数”两个词的句子

我试过了:

pdfgrep "\..*median.*exponential\." book-IntroStatistics.pdf 

但它似乎不起作用,只是给了我大量的文本。

【问题讨论】:

  • 试试"[^?!.]*median[^?!.]*exponential[^?!.]*"
  • 嗯,然后我得到 ` -bash: !.]*median[^?!.]*exponential[^?!.]*": event not found `
  • 那是因为!,转义。 '[^?\!.]*median[^?\!.]*exponential[^?\!.]*'
  • 谢谢!完美运行。

标签: grep


【解决方案1】:

你可以使用

pdfgrep '[^?\!.]*median[^?\!.]*exponential[^?\!.]*' book-IntroStatistics.pdf

[^?\!.]* 部分匹配除 ?!. 字符之外的任何 0+ 字符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-26
    • 1970-01-01
    相关资源
    最近更新 更多