5

ack (the grep tool written in Perl) does not find a file that grep -r finds, and I cannot find the right options to get it to work. The following shows ack did not find the target string, which is in a regular file in a sub-directory. It's on Bash shell (Ubuntu 11.04):

100 $ grep -r imbue *
    hel/find:              the  fact that some shells including Bash imbue braces
    ## Note: grep find it as shown in the above.

101 $ ./ack-standalone   imbue  
    ## Note: ack didn't find it as shown in the above.

102 $ ./ack-standalone   --version
    ack 1.96
    Running under Perl 5.10.1 at /usr/bin/perl

    Copyright 2005-2011 Andy Lester.

    This program is free software.  You may modify or distribute it
    under the terms of the Artistic License v2.0.

    ## This is the testing folder structure:
103 $ tree
    .
        ack-standalone
        hel
          |-  dot
          |-  find
          |-  grep
          |-  jobs
        perlman
        perlre
        perlrequick
        perlrun
        perlvar
        xargs

    1 directory, 11 files

Version 2 of ack, from apt-get package installation, got same results. In the stand-alone version (version 1) shown above. ack -f shows nothing, and I tried the -r and * options, all with the same results.

On another machine, Ubuntu 10.04, it works like a charm.

Joshua Goldberg
  • 5,059
  • 2
  • 34
  • 39
Andrew_1510
  • 12,258
  • 9
  • 51
  • 52

1 Answers1

8

It works for me if I select to operate in all files regardless of its type, using -a switch (my version is same that yours):

ack -a imbue *
Birei
  • 35,723
  • 2
  • 77
  • 82
  • Ack 1.x only searches files of types it understands. Basically, ack only searches source code in files that it recognizes as source code based on the extension. It is NOT a general purpose grep replacement. Also, in the `ack -a imbue *` example there, the `*` should not be included. You never want to specify a filename to ack unless you have a reason to specify a filename to ack. – Andy Lester Mar 29 '12 at 06:51
  • 'It is not a general purpose grep replacement.' The first line of `ack` man page states: "Ack is designed as a replacement for 99% of the uses of grep." – jwg Jan 15 '14 at 15:45