β

The best grep tool in the world; ripgrep

Peterbe.com 82 阅读

tl;dr; ripgrep (aka. rg ) is the best tool to grep today.

ripgrep is a tool for searching files. Its killer feature is that it's fast. Like, really really fast. Faster than sift , git grep , ack , regular grep etc.

If you don't believe me, either read this detailed blog post from its author or just jump straight to the conclusion :

Benchmark
Benchmark

I used to use git grep whenever I was inside a git repo and sift for everything else. That alone, was a huge step up from regular grep . Granted, almost all my git repos are small enough that regular git grep is faster than I can perceive many times. But with ripgrep I can just add --no-ignore-vcs and it searches in all the files mentioned in .gitignore too. That's useful when you want to search in your own source as well as the files in node_modules .

The installation instructions are easy. I installed it with brew install ripgrep and the best way to learn how to use it is rg --help . Remember that it has a lot of cool features that are well worth learning. It's written in Rust and so far I haven't had a single crash, ever. The ability to search by file type gets some getting used to (tip! use: rg --type-list ) and remember that you can pipe rg output to another rg . For example, to search for all lines that contain query and string you can use rg query | rg string .

作者:Peterbe.com
Peter Bengtssons's personal homepage about little things that concern him.
原文地址:The best grep tool in the world; ripgrep, 感谢原作者分享。

发表评论