rg
ripgrep — fast recursive search tool that respects .gitignore by default.
Synopsis
rg [OPTION]... PATTERN [PATH]...
Examples
rg 'TODO' src/
rg -t py 'import os'
rg -l 'deprecated'
rg -C 3 'panic' --type rust
rg --json 'error' | head
Common options
| Flag | Description |
|---|---|
| -i | Case-insensitive |
| -n | Show line numbers (default) |
| -l | List matching files only |
| -t | Search only files of given type |
| -g | Include/exclude glob pattern |
| -C | Show N lines of context |
| -c | Count matches per file |
About rg
The `rg` command ripgrep — fast recursive search tool that respects .gitignore by default. Search commands help you locate files, text patterns, and executables across the filesystem.
Efficient searching is critical when working with large codebases or troubleshooting system issues. These tools range from simple filename lookups to full regular-expression pattern matching across file contents.
The command accepts 7 commonly used flags shown above, though the full set of options is available in the man page (`man rg`). The 5 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.
Related commands
More Search Commands
Other commands in the Search category