For a system admin or a programmer, grep and the likes are probably the most popular tools when it comes to searching through complex configuration directories and large trees of source code for a particular text string or pattern.

If grep is one of your favorite tools, chances are that you will like ack even more. ack is a Perl-based command-line utility similar to grep, but designed to improve the search speed and capabilities of grep. Especially if you are a programmer, I strongly recommend replacing grep with ack. The usage of ack is heavily optimized for code search, so a programmer like you can perform complex search on source code trees with fewer keystrokes.

Print line numbers in search results, which helps find the code later.

Can search for a specific file type (e.g., Perl, C++, Makefile) (which may have multiple suffixes).

Highlight search results by color.

Support Perl's advanced regular expression which is more expressive than GNU regular expression used by grep.

As for search speed, ack is generally faster than grep. The speed of ack comes from its built-in file type filters; ack maintains a list of recognizable file types, and skips unknown/unnecessary file types during search. It also avoids inspecting superfluous metadata directories.

Install ack on Linux

While ack is available as a standard package on major Linux distros (e.g., ack-grep package on Debian-based system, and ack package for Redhat-based system), the version of ack shipped with the distros still remains 1.x, while ack 2.0 with more features has already become available.

So I am going to download and install ack from the official site.

Conveniently, ack is available as a single-file Perl script from the official site, which incorporates all dependent Perl modules in it. So you don't need to install any extra Perl modules to run the script.

To intall ack on your Linux system, go to the official site to download the latest ack. As of this writing, the latest version is 2.12.

Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

Please note that the URL given only installs ack 2.12. Chances are that there will have been a newer version than 2.12 by the time people read this. Best to go to http://beyondgrep.com/install/ to get the latest and greatest.