【问题标题】:Why might ack miss files that grep finds?为什么 ack 可能会丢失 grep 找到的文件?
【发布时间】:2014-04-02 13:48:01
【问题描述】:

在 Ubuntu 服务器机器上考虑这个结果:

 - awsZeta():postfix$ ack virtual
 - awsZeta():postfix$ ack -r virtual
 - awsZeta():postfix$ grep -r virtual *
main.cf:# this specifies where the virtual mailbox folders will be located
main.cf:virtual_mailbox_base = /var/spool/mail/virtual
main.cf:virtual_mailbox_maps = mysql:/etc/postfix/mysql_mailbox.cf
main.cf:virtual_alias_maps = mysql:/etc/postfix/mysql_alias.cf
main.cf:virtual_mailbox_domains = mysql:/etc/postfix/mysql_domains.cf
main.cf:# this is how to connect to the domains (all virtual, but the option is there)
main.cf:virtual_uid_maps = static:5000
main.cf:virtual_gid_maps = static:5000
master.cf:virtual   unix  -       n       n       -       -       virtual
master.cf:#  virtual_transport = lmtp:inet:localhost
postfix-files:$daemon_directory/virtual:f:root:-:755
postfix-files:$config_directory/virtual:f:root:-:644:p1
postfix-files:$manpage_directory/man5/virtual.5:f:root:-:644
postfix-files:$manpage_directory/man8/virtual.8:f:root:-:644
postfix-files:$sample_directory/sample-virtual.cf:f:root:-:644:o
postfix-files:$html_directory/virtual.5.html:f:root:-:644
postfix-files:$html_directory/virtual.8.html:f:root:-:644
 - awsZeta():postfix$ ack --version
ack-grep 1.92
Running under Perl 5.14.2 at /usr/bin/perl

Copyright 2005-2009 Andy Lester.

This program is free software; you can redistribute it and/or modify
it under the terms of either: the GNU General Public License as
published by the Free Software Foundation; or the Artistic License.

为什么ack 会错过这些结果?我怎样才能让 ack 表现得像 grep -r foobar *,它表面上是这样做的?这可能是由于使用的是 2.0 之前的 Ack 版本吗?

【问题讨论】:

    标签: ack


    【解决方案1】:

    是的,这是因为您使用的是 pre-2.0 ack。

    ack 1.x 仅搜索已知为源代码的已知文件类型。它不是 grep 的通用替代品。

    ack 2.x 默认搜索它找到的任何文本文件,无论它是否属于已知的源代码类型,如 .c 或 .php。

    来自http://beyondgrep.com/ack-2.0/

    当没有指定选择器时,ack 1.x 只搜索它可以映射到文件类型的文件。相反,ack 2.x 将搜索每个没有通过 --ignore-file 或 --ignore-dir 明确忽略的常规非二进制文件。这类似于 ack 1.x 中 -a/--all 选项的行为。

    【讨论】:

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