Top 10 reasons to use ack for source code

1. It's fast

Ack only searches the stuff that makes sense to search. Perl's regular expressions are highly optimized.

2. It's portable

ack is pure Perl, so it runs on Windows just fine. It has no dependencies other than Perl 5. Installation is a snap.

3. It ignores VCS directories

ack searches recursively by default, while ignoring .git, .svn, CVS and other VCS directories.

Which would you rather type?

$ grep pattern $(find . -type f | grep -v '\.git')

$ ack pattern

4. Better search results

Since ack defaults to only searching source code, you get fewer false positives.

5. Easy filetype specifications

If you have a big project with many different languages combined, it's easy to add --perl to search only Perl files, or use --nohtml to search everything except HTML.

ack's filetype detection means more than just specifying a single file extension.

Which would you rather type?

$ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .git)

$ ack --perl pattern

Plus, ack does filetype detection that find can't. ack checks the shebang lines of scripts without extensions.

6. Creates lists of files without searching

Since ack can know to search only, say, Ruby files with the --ruby switch, you can also generate a list of files in a tree with the -f switch.

# List all Ruby files in the tree
$ ack -f --ruby > all-ruby-files

7. Match highlighting

ack has flexible match highlighting, where you can specify the colors to use in its output.

8. Perl regular expressions

Perl leads the programming world with its regular expressions. ack uses Perl's regular expressions, not a "Perl-compatible" subset.

You can also take advantage of Perl's match variables. For example, to generate a list of all files #included in your C code, use this:

ack --cc '#include\s+<(.*)>' --output '$1' -h

9. Command switches much like GNU grep

If you know GNU grep, you know most of ack's switches, too. Word-only searching with -w, case-insensitive searching with -i, etc

10. "ack" is shorter than "grep" to type

This one is sort of a joke, but sort of not. You spend hours every day searching through source code. ack makes it as quick and easy as possible to do that searching and to remove as much drudgerous typing as possible.

Defaults matter. The less typing you have to do, the better.

What are you waiting for?

Installation is a snap. Try ack for yourself.

Ack in five minutes

A lightning talk by Cameron Pope on why you should use ack.


"Every once in a while something comes along that improves an idea so much, you can't ignore it. Such a thing is Ack, the grep replacement." --

"Whoa, this is *so* much better than grep it's not even funny." -- Jacob Kaplan-Moss, creator of Django.

"Thanks for creating ack and sharing it with the world. It makes my days just a little more pleasant. I'm glad to have it in my toolbox. That installation is as simple as downloading the standalone version and chmodding is a nice touch." -- Alan De Smet

"I came across ack today, and now grep is sleeping outside. It's very much like grep, except it assumes all the little things that you always wanted grep to remember, but that it never did. It actually left the light on for you, and put the toilet seat down." -- Samuel Huckins

"ack is the best tool I have added to my toolbox in the past year, hands down." -- Bill Mill on reddit

"I use it all the time and I can't imagine how I managed with only grep." -- Thomas Thurman

"This has been replacing a Rube Goldberg mess of find/grep/xargs that I've been using to search source files in a fairly large codebase." -- G. Wade Johnson

"You had me at --thpppt." -- John Gruber, Daring Fireball

"Grepping of SVN repositories was driving me crazy until I found ack. It fixes all of my grep annoyances and adds features I didn't even know I wanted." -- Paul Prescod

"I added ack standalone to our internal devtools project at work. People are all over it." -- Jason Gessner

"I just wanted to send you my praise for this wonderful little application. It's in my toolbox now and after one day of use has proven itself invaluable." -- Benjamin W. Smith

"ack has replaced grep for me for 90% of what I used it for. Obsoleted most of my 'grep is crippled' wrapper scripts, too." -- Randall Hansen

"ack's powerful search facilities are an invaluable tool for searching large repositories like Parrot. The ability to control the search domain by filetype--and to do so independent of platform--has made one-liners out of many complex queries previously done with custom scripts. Parrot developers are hooked on ack." -- Jerry Gay

"That thing is awesome. People see me using it and ask what the heck it is." -- Andrew Moore

"ack is certainly one of those simple pleasures of life on the command line." -- Michael Lehmkuml