ripgrep
A line-oriented search tool that recursively searches directories for a regex pattern, respecting gitignore rules.
ripgrep (also known as rg) is an extremely fast alternative to tools like
grep, ag, and ack. It combines the raw speed of
ag with the correctness of
GNU grep, while automatically respecting .gitignore rules and skipping hidden
or binary files by default.
Features
- Blazing fast — consistently outperforms other search tools in benchmarks
- Regex support — full Perl-compatible regular expressions via the
regexcrate - Respects
.gitignore— skips ignored, hidden, and binary files automatically - Unicode-aware — searches UTF-8, UTF-16, and other encodings
- Colored output — highlights matches with terminal colors out of the box
- Multiline search — can match patterns that span multiple lines
Installation
cargo install ripgrep
Or via your system package manager:
# Debian/Ubuntu
apt install ripgrep
# macOS
brew install ripgrepUsage
# Search for a pattern recursively in the current directory
rg "fn main"
# Search only in Rust files
rg "fn main" --type rust
# Case-insensitive search
rg -i "error"
# Show context lines around matches
rg -C 3 "TODO"
# Search for a fixed string (no regex)
rg -F "some.literal.string"