为什么ack会错过grep发现的文件?

时间:2014-04-02 13:48:01

标签: ack

在Ubuntu Server计算机上考虑此结果:

 - 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版本?

1 个答案:

答案 0 :(得分:2)

是的,这是因为你使用的是2.0之前的确认。

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选项的行为。