Number Lines With nl

Prefix each line with a number, with control over formatting and ranges.

LinuxtextcliLow risk
Run nl -ba file.txt to number all lines including blanks.

01Command

Command
$ nl -ba file.txt

02What 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

RiskLow risk
RequirementsPreinstalled on Linux (GNU coreutils)
!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

Last verified: 2026-10-13 · Category: Developer

06Related solutions