ack is like grep, but better. Especially if you’re using it for source code. If you don’t have ack yet, and you program, do yourself a favor and run:

$ cpan App::Ack

I assume you’re running Linux or OS X by saying that. If you’re on Windows, run:

ppm> install ack

(Thanks to Matthew Wilson for the proper instructions for Windows. Takin’ one for the team.)

ack is for searching a codebase for various things. It supports regex search and is smart about what to search and what to ignore. By default, it only searches through source code files (no, not just Perl source code). It also by default operates recursively. It also knows to exclude subversion and CVS special folders. Brilliant.

ack’s output is similar to grep, except that matches are highlighted for you, making it a million times easier to read.

$ ack printf

ack output example

It also features a very useful switch which yields endless hours of entertainment:

$ ack --thppppppt!

_   /|
   U    ack --thppppppt!

So give ack a try and send a thank-you email off to Andy Lester for making your life a bit easier.


TrackBack URL for this entry:


TRS-80 said:

export GREP_OPTIONS="--color=auto" for highlighting when you're forced to use grep.

Matthew Wilson said:

For ActiveState Perl on Windows, it seems to be:


install ack

Similar to TRS-80's solution, I do this:

alias grep='grep --color=always'

in my .bashrc


This article was published on August 12, 2006 7:41 PM.

The article previously posted was utime.

The next article is On Apple's Showtime Event.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type