nl flags & options

Basic usage

Number non-empty lines of a file.

nl file.txt

-b, --body-numbering

Control which lines get numbered. a = all, t = non-empty (default), n = none.

nl -b a file.txt
nl -b n file.txt

-n, --number-format

Set the number format. ln = left-justified, rn = right-justified (default), rz = right-justified with zeros.

nl -n rz file.txt
nl -n ln file.txt

-s, --number-separator

Set the string between number and line content.

nl -s '. ' file.txt
nl -s '  ' file.txt

-w, --number-width

Set the width of the line number column.

nl -w 3 file.txt

-v, --starting-line-number

Start numbering from a specific number.

nl -v 100 file.txt

-i, --line-increment

Set the numbering increment.

nl -i 5 file.txt

Pipe usage

cat -s log.txt | nl