nl

NAME

nl - filter to number lines

SYNOPSIS

nl [-p] [-b type] [-d delim] [-h type]
   [-i incr] [-l num] [-n  format] [-s sep]
   [-v startnum] [-w width] [file]

DESCRIPTION

The nl(1) utility reads lines from standard input or from file and writes those lines to standard output, with line numbers added on the left.

The input text is treated in terms of logical pages

Line numbers restart at the beginning of each logical page. A logical page contains a header, a body, and a footer, any of which can be empty. Each section of a logical page can have its own numbering. For instance, headers can have no numbers; blank lines, however, are numbered in the body, but not in the footer.

The sections of a logical page are indicated by the following delimiters, which occur alone on an input line:

Line Start of
\:\:\: header
\:\: body
\: footer
By default, a file contains only one logical page body.

The nl(1) utility takes the following options:

-b type
Specify the logical body lines to be numbered. Values for type are:
a
All lines are numbered.
n
No line numbering.
pregexp
Number only the lines containing the specified regular expression regexp.
t
Number only lines consisting entirely of text characters classified as graph characters in the current locale.
-d delim
Set the delimiter characters from \: to the one or two characters specified by delim. If only one character is specified, the second is a colon (:).
-f type
Specify the logical footer to be numbered. The values of type are the same as for -b.
-h type
Specify numbering for the logical header section. The values of type are the same as for -b.
-i incr
Increment the numbers of the logical page lines by incr. The default is 1.
-l num
Treat num blank lines as 1. The default is 1. A value of -l 3 means that only the third adjacent blank line is numbered if the logical section has numbering turned on.
-n format
Number the lines in the specified format. Values for format are:
ln
Left justified with leading zeroes suppressed.
rn
Right justified with leading zeroes suppressed. This is the default.
rz
Right justified with leading zeroes retained.
-p
Preserve numbering; do not restart it at logical page delimiters.
-s sep
Separate the line number and the text characters by the characters in the string sep. The default value of sep is a tab character.
-v startnum
Begin numbering logical page lines with the value startnum. The default is 1.
-w width
Use width characters for the line number. The default is 6.

DIAGNOSTICS

The nl(1) utility returns 0 on success and >0 if an error occurred.

SEE ALSO

cat(1)

pr(1)