nl - Numbers lines in a file
nl [-b type] [-d delimiter1[delimiter2]] [-f type] [-h type] [-i number] [-l number] [-n format] [-p] [-s [separator]] [-vnumber] [-wnumber] [file]
Interfaces documented on this reference page conform to industry standards as follows:
nl: XPG4, XPG4-UNIX
Refer to the
reference page for more information
about industry standards and associated tags.
Use the following options to change the default settings. Specifies which body section lines to number. The recognized types are as follows: Numbers all lines. Number only lines with text consisting of at least one character in the current locale's graph character classification. Does not number any lines. Numbers only those lines containing the specified pattern. The full range of regular expressions is supported for pattern.
The path name of a file in which the lines are to be numbered.
is not specified, standard input is used.
The nl command reads file (standard input by default), numbers the lines in the input, and writes the numbered lines to standard output.
In the output, nl numbers the lines on the left, according to the options you specify on the command line.
The input text must be written in logical pages. Each logical page has a header, a body, and a footer section (sections can be empty). Unless you use the -p option, nl resets the line numbers at the start of each logical page. You can set line numbering options independently for the header, body, and footer sections (for example, no numbering of header and footer lines while numbering text lines only in the body).
Signal the start of logical page sections with lines in file that contain nothing but the following delimiter characters (assuming the default delimiters--see the description of the -d option):
|Line Contents||Start of|
You can name only one file on the command line. You can list the options
and the file name in any order.
The following exit values are returned:
An error occurred.
To number only the nonblank lines, enter: nl chap1
You can't kill time without injuring eternity.
0020::You can't kill time without injuring eternity.
The following environment variables affect the execution of
Provides a default value for the internationalization variables
that are unset or null. If
is unset or null, the corresponding value from the default locale is used.
If any of the internationalization variables contain an invalid setting, the
utility behaves as if none of the variables had been defined.
If set to a non-empty string value, overrides the values of
all the other internationalization variables.
Determines the locale for the interpretation of sequences
of bytes of text data as characters (for example, single-byte as opposed to
multibyte characters in arguments and input files), the behavior of classes
within regular expressions, and for deciding which characters are in character
Determines the locale for the format and contents of diagnostic
messages written to standard error.
Determines the location of message catalogues for the processing
Commands: cat(1), pr(1)