Show matches with file and line context.
Section: ripgrep (rg)
Search with line numbers
bash
bash
rg -n 'useState' src/Explanation
Line numbers are included by default in many rg outputs, but `-n` makes it explicit.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing ripgrep (rg)
Literal string search in ripgrep
Disable regex parsing for a search term.
Recursive search with line numbers
Show file names and line numbers for matches.