line numbering filter
nl utility reads lines from the named
file, applies a configurable line numbering filter
operation, and writes the result to the standard output. If
file is a single dash (‘-’) or absent,
nl reads from the standard input.
nl utility treats the text it reads in
terms of logical pages. Unless specified otherwise, line numbering is reset
at the start of each logical page. A logical page consists of a header, a
body and a footer section; empty sections are valid. Different line
numbering options are independently available for header, body and footer
The starts of logical page sections are signaled by input lines containing nothing but one of the following sequences of delimiter characters:
If the input does not contain any logical page section signaling directives, the text being read is assumed to consist of a single logical page body.
The following options are available:
- Specify the logical page body lines to be numbered. Recognized
type arguments are:
- Number all lines.
- Number only non-empty lines.
- No line numbering.
- Number only those lines that contain the basic regular expression specified by expr.
The default type for logical page body lines is t.
- Specify the delimiter characters used to indicate the start of a logical page section in the input file. At most two characters may be specified; if only one character is specified, the first character is replaced and the second character remains unchanged. The default delim characters are ‘\:’.
- Specify the same as
-btype except for logical page footer lines. The default type for logical page footer lines is n.
- Specify the same as
-btype except for logical page header lines. The default type for logical page header lines is n.
- Specify the increment value used to number logical page lines. The default incr value is 1.
- If numbering of all lines is specified for the current logical section
using the corresponding
-ha option, specify the number of adjacent blank lines to be considered as one. For example,
-l2 results in only the second adjacent blank line being numbered. The default num value is 1.
- Specify the line numbering output format. Recognized
format arguments are:
- Left justified.
- Right justified, leading zeros suppressed.
- Right justified, leading zeros kept.
The default format is rn.
- Specify that line numbering should not be restarted at logical page delimiters.
- Specify the characters used in separating the line number and the corresponding text line. The default sep setting is a single tab character.
- Specify the initial value used to number logical page lines; see also the
description of the
-poption. The default startnum value is 1.
- Specify the number of characters to be occupied by the line number; if the width is insufficient to hold the line number, it will be truncated to its width least significant digits. The default width is 6.
- The character encoding locale(1). It decides which byte sequences form characters
-doption. If unset or set to "C", "POSIX", or an unsupported value, each byte is treated as a character.
nl utility exits 0 on success,
and >0 if an error occurs.
nl utility is compliant with the
X/Open System Interfaces option of the IEEE Std 1003.1-2008
nl utility first appeared in
AT&T System III UNIX. It was added to the
OpenBSD 5.5 release.