ack - search tool (like grep) designed for programmers

ack is a great alternative to grep especially when dealing with large trees of heterogeneous source code.

If you find yourself doing something like this often: grep -ri "some text" | grep -v .svn
ack is the answer to your misery!

screenshot of ack in action

ack will by default recursively search for files and automatically exclude binary files, core dumps, and directories used by version control systems (.svn, .git, CVS) . It is also works a lot faster than grep!

Search results can also be filtered using additional options. For example, to exclude matches found in your HTML and LaTeX documentation, you can use:

ack --nohtml --notex MPI_Issend

Alternatively, you can limit you searches to specific file types. For example, to only search in Fortran source files:

ack --fortran MPI_Issend

The --fortran option will limit the search to only files with the following extensions: .f .f77 .f90 .f95 .f03 .for .ftn .fpp

For more information about supported options and file types as well as for installation instructions, visit the ack homepage.

Tips:

  • If your search string results in lots of matches, include the following option to ack : --pager="less -R". This will paginate your results using the less command while maintaining the colours.