ripgrep Basics/Show line numbers explicitly

Display matching lines with line numbers.

Section: Basic search

Show line numbers explicitly

bash
bash
rg -n 'apiKey' config/
Explanation

ripgrep usually shows line numbers for multi-file searches, but `-n` makes the intent explicit and is handy in aliases/scripts.

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 Basic search
Search recursively in the current directory
Search for a pattern using ripgrep's recursive defaults.
OpenIn sheetbashsame section
Search inside a specific path
Limit the search to one directory or file.
OpenIn sheetbashsame section
Case-insensitive search
Match regardless of letter case.
OpenIn sheetbashsame section
Use smart case matching
Lowercase patterns search case-insensitively; uppercase triggers case-sensitive search.
OpenIn sheetbashsame section
List only file names with matches
Return matching file paths without printing the matching lines.
OpenIn sheetbash1 tag match
Search standard input
Use ripgrep in a pipeline.
OpenIn sheetbash1 tag match