【问题标题】:Is it possible to exclude comments from searches using silversearcher是否可以使用 silversearcher 从搜索中排除评论
【发布时间】:2014-03-13 17:48:52
【问题描述】:

我正在搜索包含大注释块的文件。这些注释块包含 javadoc 样式代码 cmets,其中还包含我正在搜索的关键字。

对于类似的查询,

$ ag compute

我想排除在包含关键字compute 的此类注释块中找到的任何匹配项。 silversearcher 可以做到这一点吗?也欢迎任何解决此问题的替代方法。

谢谢。

【问题讨论】:

标签: bash shell command-line terminal grep


【解决方案1】:

你可以试试这样的。它将过滤所有带有* 的行。

ag 'TODO' . | grep -v '*'

此解决方案并不完美,但--ignore 仅适用于文件。如果有人有更好的解决方案,我也很感兴趣。

【讨论】:

    猜你喜欢
    • 2015-04-07
    • 2014-01-28
    • 1970-01-01
    • 2015-03-18
    • 2017-02-13
    • 2011-06-12
    • 1970-01-01
    • 2020-05-16
    • 2014-12-09
    相关资源
    最近更新 更多