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
List only file names with matches
rg -l 'useEffect' app/

# Return matching file paths without printing the matching lines.

List files without matches
rg -L 'Copyright 2026' .

# Find files that do not contain a pattern.

Count matches per file
rg -c 'console\.log' src/

# Show how many matches exist in each file.

Count matching lines globally
rg -c 'ERROR' app.log

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

Show available built-in file types
rg --type-list | less

# Print ripgrep's known type definitions.

## Pipes and stdin
Search standard input
git diff --cached | rg '^\+'

# Use ripgrep in a pipeline.

Search logs from another command
journalctl -u nginx --since today | rg -i 'timeout|error'

# Filter live or recent command output with rg.

Search file lists or command results
fd . src | rg '/tests?/'

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

Treat input as NUL-separated data
printf 'alpha\0beta\0gamma\0' | rg -z 'beta'

# Search data that uses NUL delimiters instead of newlines.

Emit machine-readable JSON results
rg --json 'panic!' src/

# Use structured output for editor integrations and automation.

Recommended next

No recommendations yet.