https://github.com/ggreer/the_silver_searcher#how-is-it-so-fast尝试了下,比ack快多了,完虐grep当然更是毫无压力。
安装后用法和ack类似,ag xxx即可
How is it so fast?
Searching for literals (no regex) uses Boyer-Moore-Horspool strstr.
Files are mmap()ed instead of read into a buffer.
If you're building with PCRE 8.21 or greater, regex searches use the JIT compiler.
Ag calls pcre_study() before executing the regex on a jillion files.
Instead of calling fnmatch() on every pattern in your ignore files, non-regex patterns are loaded into an array and binary searched.
Ag uses Pthreads to take advantage of multiple CPU cores and search files in parallel.