ripgrep: Fast, Gitignore-Aware Regex Search
ripgrep is a command-line tool that recursively searches a directory for a regex pattern, skipping anything covered by your .gitignore by default. Reach for it when you're searching a real codebase and want that filtering plus Unicode support and an optional PCRE2 engine without extra setup. Skip it if you need a POSIX-standard tool guaranteed to exist everywhere: the README itself names plain grep as the better fit.
What is ripgrep?
ripgrep, run from the terminal as rg, is a line-oriented tool built on Rust's regex engine, walking every file beneath the directory where you launch it and printing matching lines. By default it skips files ignored by .gitignore, .ignore, or .rgignore, along with hidden files and binary files; that filtering turns off with rg -uuu. The binary is called rg. Licensing gives you a choice between MIT and the Unlicense.
Core features for developers
- ✓Recursive, gitignore-aware search by default: ripgrep skips files matched by .gitignore, .ignore, or .rgignore, plus hidden files and binary files, unless you turn it off with rg -uuu.
- ✓File-type filtering on the fly: rg -tpy foo limits a search to Python files, rg -Tjs foo excludes JavaScript, and new extensions can be taught to ripgrep through rules you define yourself.
- ✓Unicode support that's always on, built directly into the underlying finite-automaton regex engine instead of toggled as a slower opt-in mode.
- ✓An optional PCRE2 backend (-P/--pcre2, or --auto-hybrid-regex to use it only when needed) that adds look-around and backreference matching the default engine doesn't support.
- ✓Search inside compressed files, covering formats like gzip, zstandard, bzip2, xz, lz4, lzma, and brotli, using the -z/--search-zip flag.
- ✓Read text encodings beyond UTF-8, including UTF-16, latin-1, GBK, EUC-JP, and Shift_JIS, via the -E/--encoding flag, with some automatic UTF-16 detection.
- ✓Rudimentary find-and-replace on matches, arbitrary input-preprocessing filters (PDF text extraction, custom decompression, decryption), and a configuration file for flags you always want on.
- ✓Picks memory-mapped search for single files versus incremental buffered search for large directory trees automatically, and walks directories with a lock-free parallel iterator built on the crossbeam and ignore crates.
Installing ripgrep
ripgrep's binary is named rg. Every GitHub release publishes precompiled archives for Windows, macOS, and Linux, and the Linux and Windows builds are static executables, so a platform not covered by a package manager below can just grab those. Package managers cover most setups: Homebrew and MacPorts on macOS; Chocolatey, Scoop, and Winget on Windows; native repos on Arch (pacman), Gentoo (emerge), Fedora (dnf), openSUSE Tumbleweed and Leap 15.1+ (zypper), Debian and Ubuntu Cosmic and newer (apt-get, though Debian stable's version can lag the direct .deb download), Void Linux (xbps-install), FreeBSD (pkg), OpenBSD (pkg_add), NetBSD (pkgin), Haiku (pkgman), Nix (nixpkgs), Flox, and Guix. CentOS Stream 10, RHEL 10, and Rocky Linux 10 install it through the EPEL repository after enabling the crb/codeready-builder repo. Rust developers can skip all of that and run cargo install ripgrep or cargo binstall ripgrep directly; building from source needs Rust 1.96.0 or newer.
Basic ripgrep usage
Basic searches start with rg 'pattern', which recurses through the current directory using gitignore-aware filtering. Narrow by file type with rg -tpy foo (Python only) or exclude a type with rg -Tjs foo (skip JavaScript); ripgrep also lets you register custom file-type rules. Turn off all automatic filtering with rg -uuu when you deliberately want to search ignored, hidden, or binary content. Switch regex engines with -P/--pcre2 (or --auto-hybrid-regex) when a pattern needs look-around or backreferences, search inside compressed archives with -z/--search-zip, and point -E/--encoding at a non-UTF-8 file when needed. Persistent flags can live in a configuration file instead of being retyped every run.
Strengths
- ✓Gitignore-aware recursive search plus automatic skipping of hidden and binary files, on by default rather than something you configure.
- ✓Unicode support that's always on, not a slower opt-in mode you have to remember to enable.
- ✓Ships as a single static binary with precompiled downloads for every release, backed by packages in most major package managers.
- ✓The optional PCRE2 engine adds look-around and backreference matching without giving up the default engine's speed for everyday patterns.
- ✓A choice of MIT or the Unlicense for licensing, so it isn't a blocker for any kind of use.
When other tools might be better
- △ripgrep isn't POSIX-standard; its own README names plain grep as the better choice when you need a portable, standards-conforming tool guaranteed to be on every machine.
- △Look-around and backreferences only work through the optional PCRE2 engine (-P/--pcre2 or a pcre2 build feature); they aren't available in the default regex engine.
- △Building from source requires Rust 1.96.0 or newer, so contributors on an older toolchain need to upgrade before they can compile it.
- △Precompiled binaries include debug symbols by default, which makes them larger than expected until you run strip on them yourself.
- △The README's own list of reasons not to use ripgrep is partly open-ended: it also cites an unnamed missing feature or bug, or an unspecified performance edge case, rather than enumerating every gap.
ripgrep vs. other search tools
Common questions about ripgrep
ripgrep is dual-licensed: you can use it under the MIT license or under the Unlicense, whichever fits your project's requirements.
ripgrep runs on Windows, macOS, and Linux, and every GitHub release publishes precompiled binaries for all three, alongside packages in most major package managers.
ripgrep covers most everyday grep use cases, but its own README stops short of a full replacement claim: it doesn't conform to POSIX, so plain grep is still the safer pick when you need strict portability.
ripgrep supports full Unicode matching by default, with UTF-8 decoding built directly into its underlying regex engine rather than switched on separately.
ripgrep can search inside compressed files in several formats, such as zstandard, lzma, xz, lz4, gzip, bzip2, and brotli, using the -z/--search-zip flag.
ripgrep supports PCRE2 as an optional engine, turned on with -P/--pcre2 or --auto-hybrid-regex, adding look-around and backreference matching the default engine doesn't have.
The problem it solves
Grepping a real project with plain grep also matches inside build output, node_modules, vendor directories, and anything else your .gitignore already excludes, so you end up maintaining a growing list of --exclude flags or piping the search through find first. ripgrep's own README frames its reason for existing around that exact friction: gitignore-aware filtering, plus skipping hidden and binary files, built in as default behavior instead of something you configure by hand every time.
Best use cases
- •Searching a large codebase for a function or string without hand-writing exclude paths for build output, since gitignore rules apply automatically.
- •Narrowing a search to one file type on the fly with -tpy or -Tjs instead of maintaining a list of extensions yourself.
- •Searching logs or datasets stored in an encoding other than UTF-8, like Shift_JIS, GBK, or latin-1, via -E/--encoding.
- •Searching straight inside a compressed archive (gzip, zstandard, and others) with -z/--search-zip instead of decompressing it first.
- •Writing a pattern that needs look-around or backreferences by switching to the PCRE2 engine with -P.
Who should try it — and who should skip
Try ripgrep if you search source trees often and want gitignore-aware defaults, full Unicode support, and an opt-in PCRE2 engine for the patterns that need it. Skip it if you need a tool that's POSIX-standard and guaranteed to already be installed everywhere; the README itself defers to plain grep for that job.
Related repositories
Still deciding about ripgrep?
One click hands the question to an AI along with this page — see what it says about ripgrep.
