ack (on Ubuntu named ack-grep, so if you’re using Ubuntu then replace ack in the example commands in this article with ack-grep) is a friendlier alternative to grep for most uses. One of the features I really like is that ack distinguishes files by type and that you can tell ack to explicitly look at certain file types, or to exclude certain file types from your searches. File types that ack it doesn’t know about are not searched, you can get a list of all the types that ack knows by typing ack- grep –help-types.
You can define your own types based on file extensions using –type- set=name=.ext1,.ext2 and then tell ack to include or exclude those as well. You can configure the defaults for ack through a preference file (.ackrc) and/or through environmental variables (ACK_OPTIONS, ACK_PAGER, etc.).
1 2 3 4 5
Here’s a few example commands taking the above .ackrc into account:
1 2 3 4
For more information take a look at ack’s help by running ack –help.