Channels

Services

Ack 2.0 enhances the "grep for source code"

The developers of ack have released version 2.0 of their grep-like tool optimised for searching source code. Described as "designed for programmers", ack has been available since 2005 and is based on Perl's regular expressions engine. It minimises false positives by ignoring version control directories by default and has flexible highlighting for matches. The newly released ack 2.0 introduces a more flexible identification system, better support for ackrc configuration files and the ability to read the list of files to be searched from stdin.

Its developers say that ack is designed to perform in a similar fashion to GNU grep but to improve on it when searching source code repositories. The programs web site at beyondgrep.com lists a number of reasons why programmers might want to use ack instead of grep when searching through source code, the least of which being that the ack command is quicker to type than grep. But ack brings a lot more to the table than that as it is specifically designed to deal with source code and understand a large number of programming languages and tools such as build systems and version control software.

In ack 2.0, users can now search all text files, not only files that the tool knows it understands which was the behaviour in previous version. For users who prefer the old way, there is a command line switch to duplicate how ack 1.x worked. A more flexible identification system gives users more ways of specifying how ack identifies different programming languages. The latest version of ack can also read a list of files directly from stdin which allows it to be used on the receiving end of a pipe such as git ls-files | ack -x foo to search only files that appear in a given Git repository. Greater support for ackrc files allows users to have a system-wide configuration file at /etc/ackrc and also to create project specific ackrc files in their source code directories.

The developers say that in following versions, they want to create a plugin framework for the tool that allows users to write components in Perl that can be used in ack. More information about the current features in ack 2.0 is available on the project's what's new page. The tool is licensed under the Artistic License 2.0 and is available to install as a Perl CPAN module. It has also been packaged for many Linux distributions, Mac OS X and FreeBSD.