ack 比 grep 更快

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

Installation

To install the latest version, use homebrew.ui

$ brew install ack

Why use ack over grep

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

Usage

$ 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 asthis

$ ack --js pancakes

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

$ ack -L brew

Customization

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

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.homebrew

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

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

--sort-files
--color

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

$ ack --dump

Alternatives to ack

There's The Silver Surfer which describes itself as ait

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

相關文章
相關標籤/搜索