Number lines of files.

Synopsis

nl [OPTION]... [FILE]...

Description

Writes each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.

Options

-b STYLE Body numbering style: a (all), t (non-empty), n (none).

-n FORMAT Number format: ln (left), rn (right), rz (right, zero-padded).

-w WIDTH Number width (default: 6).

-s SEP Separator after number (default: TAB).

-v START Starting line number (default: 1).

-i INCR Line number increment (default: 1).

Examples

$ nl file.txt

Number non-empty lines.

$ nl -ba file.txt

Number all lines, including blanks.

$ nl -n rz -w 3 file.txt

Right-justified, zero-padded line numbers.

See Also

cat, column