NL(1)NL(1)NAMEnl - line numbering filter
/usr/bin/nl [-p] [-b [type]] [-d [delim]] [-f [type]]
[-h [type]] [-i [incr]] [-l [num]] [-n [format]]
[-s [sep]] [-w [width]] [-v [startnum]] [file]
/usr/xpg4/bin/nl [-p] [-b type] [-d delim] [-f type]
[-h type] [-i incr] [-l num] [-n format] [-s sep]
[-w width] [-v startnum] [file]
The nl utility reads lines from the named file, or the standard input
if no file is named, and reproduces the lines on the standard output.
Lines are numbered on the left in accordance with the command options
nl views the text it reads in terms of logical pages. 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. Differ‐
ent line numbering options are independently available for header,
body, and footer. For example, -bt (the default) numbers non-blank
lines in the body section and does not number any lines in the header
and footer sections.
The start of logical page sections are signaled by input lines contain‐
ing nothing but the following delimiter character(s):
│Line contents │ Start Of │
│\:\:\: │ header │
│\:\: │ body │
│\: │ footer │
Unless optioned otherwise, nl assumes the text being read is in a sin‐
gle logical page body.
Command options may appear in any order and may be intermingled with an
optional file name. Only one file may be named. The specified default
is used when the option is not entered on the command line.
/usr/xpg4/bin/nl options require option arguments. A SPACE character
may separate options from option arguments. /usr/bin/nl options may
have option arguments. If option-arguments of /usr/bin/nl options are
not specified, these options result in the default. The supported
Specifies which logical page body lines are to be num‐
bered. Recognized types and their meanings are:
number all lines
number all non-empty lines.
no line numbering
number only lines that contain the regular
expression specified in exp. See NOTES below.
Default type for logical page body is t (text lines num‐
Same as -btype except for footer. Default type for logi‐
cal page footer is n (no lines numbered).
The two delimiter characters specifying the start of a
logical page section may be changed from the default
characters (\:) to two user-specified characters. If only
one character is entered, the second character remains
the default character (:). No space should appear between
the -d and the delimiter characters. To enter a back‐
slash, use two backslashes.
Same as -btype except for header. Default type for logi‐
cal page header is n (no lines numbered).
incr is the increment value used to number logical page
lines. Default incr is 1.
num is the number of blank lines to be considered as one.
For example, −l2 results in only the second adjacent
blank being numbered (if the appropriate -ha, -ba, and/or
-fa option is set). Default num is 1.
format is the line numbering format. Recognized values
left justified, leading zeroes suppressed
right justified, leading zeroes suppressed
right justified, leading zeroes kept
Default format is rn (right justified).
Do not restart numbering at logical page delimiters.
sep is the character(s) used in separating the line num‐
ber and the corresponding text line. Default sep is a
startnum is the initial value used to number logical page
lines. Default startnum is 1.
width is the number of characters to be used for the line
number. Default width is 6.
The following operand is supported:
A path name of a text file to be line-numbered.
Example 1 An example of the nl command
example% nl-v10 -i10 -d!+ filename1
will cause the first line of the page body to be numbered 10, the sec‐
ond line of the page body to be numbered 20, the third 30, and so
forth. The logical page delimiters are !+.
See environ(5) for descriptions of the following environment variables
that affect the execution of nl: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
LC_MESSAGES, and NLSPATH.
The following exit values are returned:
An error occurred.
Collation table generated by localedef
Shared object containing string transformation library routines
See attributes(5) for descriptions of the following attributes:
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
│Interface Stability │ Standard │
SEE ALSOpr(1), attributes(5), environ(5), regex(5), regexp(5), standards(5)NOTES
Internationalized Regular Expressions are used in the POSIX and "C"
locales. In other locales, Internationalized Regular Expressions are
used if the following two conditions are met:
o /usr/lib/locale/locale/LC_COLLATE/CollTable is present.
o /usr/lib/locale/locale/LC_COLLATE/coll.so is not present.
Otherwise, Simple Regular Expressions are used.
Internationalized Regular Expressions are explained on regex(5). Simple
Regular Expressions are explained on regexp(5).
Mar 28, 1995 NL(1)