nl
TLDR
Number non-blank lines in a file
SYNOPSIS
nl [options] [file]
DESCRIPTION
nl numbers lines from files or standard input. By default, it numbers only non-blank lines, preserving blank lines in the output without numbers.
The command recognizes logical page sections (header, body, footer) delimited by special character sequences, allowing different numbering styles for each section. Most commonly, it's used simply to add line numbers to file contents.
Output format is customizable: numbers can be left or right justified, padded with spaces or zeros, and separated from text by any string.
PARAMETERS
-b, --body-numbering _style_
Numbering style: a (all), t (non-blank, default), n (none), pregex (pattern)-i, --line-increment _n_
Increment for line numbers (default: 1)-n, --number-format _format_
Format: ln (left, no zeros), rn (right, no zeros), rz (right, with zeros)-w, --number-width _n_
Width of line number column (default: 6)-s, --number-separator _string_
String between number and line (default: TAB)-v, --starting-line-number _n_
First line number (default: 1)-d, --section-delimiter _chars_
Characters for logical page delimiters
CAVEATS
Different from cat -n, which numbers all lines including blank ones. The logical page feature (sections) is rarely used but can cause unexpected behavior if input contains the delimiter characters (\\: by default).
HISTORY
nl originated in System V Unix and is specified by POSIX. It has been part of the GNU coreutils since the project's inception.


