Number Lines With nl
Prefix each line with a number, with control over formatting and ranges.
Run nl -ba file.txt to number all lines including blanks.
01Command
Command
$ nl -ba file.txt02What it does
nl numbers input for review, logs or cross-referencing, and unlike cat -n it can skip blank lines, set the number format and restart numbering at sections. It is a review aid built for pipelines.
03Risk
!Warning: Numbering is textual output only; it does not modify the source file.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- nl.1.en.html manual page (Debian bookworm)Evidence: Documents nl, which numbers lines of input.
Last verified: 2026-10-13 · Category: Developer