There are times where you may need to search for code snippets throughout your codebase, for example if you are planning on deprecating a function, or change the argument list etc. I used to use ‘fgrep’, but a friend locked me onto ‘ack’, which I find much more useful out of the two. You can find more information at ack’s website @ http://betterthangrep.com/.

By default ack searches are recursive, so it’s one less flag you have to pass (vs fgrep -r), not that big of a deal, but still nice. Also ack output is easier to read and can be configured to your preferences.

Basic Search

ack 'string'

Case Insensitive Search

ack -i 'string'

Exclude Dir

There may be times where you want to exclude a dir from the search, so you don’t end up a ton of permission errors for example.

ack --ignore-dir=dir 'string'