ack

ack is a search tool designed for code. It’s built to be a replacement for grep with higher speed and more options.

Installation

To install the latest version, use homebrew.

  1. brew install ack

Why use ack over grep

  • Faster
  • Skips unimportant files by default
  • It searches recursively by default
  • Customizable

Usage

  1. ack [OPTION]... PATTERN [FILES OR DIRECTORIES]

Let’s say you want to find all JavaScript files that are using the module pancakes in your project, with ack it’s as easy as

  1. ack --js pancakes

Or you may want to find all files that does not contain the word brew

  1. ack -L brew

Customization

You can customize ack to behave the way you want it to, this configuration is stored in /.ackrc.

For example, you can add a custom type to use as a flag when searching. The following configuration will allow you to only search in .md, .mkd and .markdown files using the --markdown flag.

  1. --type-set=markdown=.md,.mkd,.markdown

You can also tell ack to always sort and use colors in the result.

  1. --sort-files
  2. --color

To see what configuration ack uses you can use the dump flag.

  1. ack --dump

Alternatives to ack

There’s The Silver Surfer which describes itself as a

A code searching tool similar to ack, with a focus on speed.