Monday, February 6, 2012

How to get ack to search .txt files

By default, ack (aka ack-grep) doesn't search through text files. To get it to do this, add
--type=text
to the command. If you know you'll always want to search text files, you can create a .ackrc file in your home directory with the same command in it:

--type=text

Ack just adds anything from this file to the command.

1 comment:

  1. What version are you using? This doesn't work for me in 2015...

    ~/bin/ack --type=text
    Unknown type 'text' at /usr/share/perl5/Getopt/Long.pm line 583
    ack: Invalid option on command line

    -bash-4.1$ ~/bin/ack --version
    ack 2.14
    Running under Perl 5.10.1 at /usr/bin/perl

    ReplyDelete