Display line numbers with matches.

Section: Basic grep

Show line numbers

bash
bash
grep -n TODO src/app.js
Explanation

Line numbers make it easier to jump directly to a match.

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 grep
Search for a word
Print lines containing a pattern.
OpenIn sheetbashsame section
Case-insensitive search
Match regardless of uppercase or lowercase.
OpenIn sheetbashsame section
Count matching lines
Only show the number of matches.
OpenIn sheetbashsame section
Invert a match
Print lines that do not match.
OpenIn sheetbashsame section
Match whole words only
Avoid partial substring matches.
OpenIn sheetbashsame section
Recursive search with line numbers
Show file names and line numbers for matches.
OpenIn sheetbash2 tag match