Search

rg

ripgrep — fast recursive search tool that respects .gitignore by default.

Synopsis

syntax
rg [OPTION]... PATTERN [PATH]...

Examples

Search for TODO in source files
rg 'TODO' src/
Search only Python files
rg -t py 'import os'
List files containing 'deprecated'
rg -l 'deprecated'
Show 3 lines context around matches in Rust files
rg -C 3 'panic' --type rust
Output in JSON format for processing
rg --json 'error' | head

Common options

FlagDescription
-iCase-insensitive
-nShow line numbers (default)
-lList matching files only
-tSearch only files of given type
-gInclude/exclude glob pattern
-CShow N lines of context
-cCount 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

Related tools