【问题标题】:ACK: Exclude specific paths (a dir and its subdirs) from searchACK:从搜索中排除特定路径(目录及其子目录)
【发布时间】:2014-08-17 11:36:13
【问题描述】:

使用ACK 2.x,我可以指定命令行选项以排除某些目录出现在结果中。例如排除目录'test'I can use:

ack -v -g 'test' | ack -x pattern ('test' 可以是要排除的目录的正则表达式)

我也可以ignore a directory using .ackrc,将--ignore-dir=save.d 添加到.ackrc 或将其用作命令行选项。但似乎我不能使用 RegEx 排除路径(目录及其子目录)。我尝试添加以下内容:

--ignore-dir=match:^\/specific\/path\/to\/test\/.*$

还有以下变体

--ignore-dir=match:/^\/specific\/path\/to\/test\/.*$/

--ignore-dir=match:\/specific\/path\/to\/test\/.*

--ignore-dir=match:/specific/path/to/test/.*

--ignore-dir=match:/specific/path/to/test/

(据此用户称,--ignore-dir and --ignore-file and indeed all file-match in ack is done with regular expressions, not with shell glob patterns,但我也尝试使用 shell glob 模式。)

但这给了我:

Non-is filters are not yet supported for --ignore-dir at /usr/bin/ack line 157

从上述备选方案中取出“匹配:”部分不会产生错误,但也不排除目录。

manual 声明“不支持像 foo/bar 这样的嵌套目录”。为了解决这个问题,在至少 ACK 2.12 之前的 ACK 上,不可能排除特定的目录和子目录。只能排除 dir 与简单字符串或正则表达式匹配的所有路径。或者有没有一种无证的巧妙方法绕过这个限制?

【问题讨论】:

  • 顺便说一句,这是一个令人讨厌的限制......

标签: regex shell grep ack


【解决方案1】:

这不受支持,我很害怕。见

--ignore-dir doesn't support absolute pathnames · Issue #291 · petdance/ack2

我来这篇文章是为了类似的事情,发现上面的问题... :-(

【讨论】:

    猜你喜欢
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多