ripgrep Basics

Core `rg` searches for files, code, and text with line numbers, smart defaults, and recursive search behavior.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

File discovery and listing

Use rg to identify matching files, counts, and quick inventories before opening an editor.

List only file names with matches

Return matching file paths without printing the matching lines.

bashANYripgrepfiles
bash
rg -l 'useEffect' app/

Great for refactors and quick inventories of where an API or symbol appears.

List files without matches

Find files that do not contain a pattern.

bashANYripgrepnegativefiles
bash
rg -L 'Copyright 2026' .

Useful for cleanup tasks such as adding headers or spotting configs missing a required key.

Count matches per file

Show how many matches exist in each file.

bashANYripgrepcount
bash
rg -c 'console\.log' src/

Good for estimating cleanup scope before refactors.

Count matching lines globally

Suppress file names and count matches across stdin or a small target.

bashANYripgrepcountlogs
bash
rg -c 'ERROR' app.log

For multi-file totals, pair with shell tools such as `awk` or use JSON output for scripting.

Show available built-in file types

Print ripgrep's known type definitions.

bashANYripgreptype-list
bash
rg --type-list | less

Type filters are one of ripgrep's biggest productivity boosts in mixed-language repositories.

Pipes and stdin

Search streamed data from other shell commands or logs.

Search standard input

Use ripgrep in a pipeline.

bashANYripgrepstdinpipe
bash
git diff --cached | rg '^\+'

ripgrep works well in shell pipelines, not just on files in a directory tree.

Search logs from another command

Filter live or recent command output with rg.

bashANYripgreplogspipe
bash
journalctl -u nginx --since today | rg -i 'timeout|error'

A fast way to sift through logs without saving them to disk first.

Search file lists or command results

Use another command to produce candidate text and rg to filter it.

bashANYripgrepfdpipeline
bash
fd . src | rg '/tests?/'

ripgrep is often the second stage in command pipelines.

Treat input as NUL-separated data

Search data that uses NUL delimiters instead of newlines.

bashANYripgrepnull-data
bash
printf 'alpha\0beta\0gamma\0' | rg -z 'beta'

`-z` is helpful when working with filenames or generated data that uses NUL separators.

Emit machine-readable JSON results

Use structured output for editor integrations and automation.

bashANYripgrepjsonautomation
bash
rg --json 'panic!' src/

JSON output is ideal when a script or UI needs precise match spans and file metadata.

Recommended next

No recommendations yet.