Ack, A Code Searcher
December 10th, 2007
Ack is a tool for programmers similar to grep but made for heterogeneous source code trees. What I was impressed with upon downloading and installing it was the highlighting it does all in the terminal.
I’ve used it a few times searching through rails trunk as TextMate seems to dog when you get a bunch of files in one project. It also prominently displays the file path which you can then copy and open with the mate command.
A few reasons you might want to use ack (from the ack site, there are more there as well):
- it’s really fast
- it runs on windows
- the standalone version has no dependencies so you can throw it in ~/bin
- searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories
- let’s you specify file types
$ ack --perl pattern
Installation is really easy on a mac. Just grab the standalone version and throw it in ~/bin/ack. Note: make sure that it is executable (chmod u+x) and that ~/bin is in your path. Enjoy.
6 Responses to “Ack, A Code Searcher”
Sorry, comments are closed for this article to ease the burden of pruning spam. If you have any further comments, just send me an email.


December 11th, 2007 at 12:30 AM
Now all we need is an ack_in_project command for Textmate.
December 11th, 2007 at 01:26 AM
GNU grep has a—color feature that highlights the matching text in the terminal. It’s enabled by default on many GNU/Linux distros. GNU grep also has a recursive option, along with a list of patterns to exclude. You can use the $GREP_OPTIONS environment variable to set defaults for these options.
December 11th, 2007 at 01:32 AM
Also: http://rak.rubyforge.org/
Basically Ack in Ruby
December 11th, 2007 at 10:10 AM
great find, tnx!
December 11th, 2007 at 10:27 AM
Craig: grep’s recursive options get very tedious when you want to exclude directories. The list of patterns to exclude are also very tedious, and grep won’t look inside the file to determine filetype like ack will.
Yes, you can do most of what ack does with grep, but why?
John: Glad you dig ack!
December 12th, 2007 at 10:44 AM
I added erb. Rails 2
ruby => [qw( rb rhtml rjs rxml )],
to
ruby => [qw( erb rb rhtml rjs rxml )],