NAME
nl — line
numbering filter
SYNOPSIS
nl |
[-p][-b
type][-d delim][-f
type][-h type][-i
incr][-l num][-n format]
[-s sep][-v
startnum][-w
width][file] |
DESCRIPTION
The nl utility reads lines from the named
file or the standard input if no file is named and reproduces the lines to
standard output. Lines are numbered on the left. Additional functionality
may be provided in accordance with the command options in effect.
The nl utility 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. Different line numbering options are independently
available for header, body and footer (for example, no numbering of header
and footer lines while numbering blank lines only in the body).
The starts of logical page sections are signalled by input lines containing nothing but the following delimiter characters:
| Line | Start of |
| \:\:\: | header |
| \:\: | body |
| \: | footer |
Unless otherwise specified, nl assumes the
text being read is in a single logical page body.
OPTIONS
The nl utility supports the XBD
specification,
Utility
Syntax Guidelines , except that the options can be intermingled with
the optional file operand. Only one file can be named.
The following options are supported:
- -b type
- Specify which logical page body lines are to be numbered. Recognised types
and their meaning are:
- a
- Number all lines.
- t
- Number only non-empty lines.
- n
- No line numbering.
- pstring
- Number only lines that contain the basic regular expression specified in string .
The default type for logical page
body is t (text lines numbered). -d
delim Specify the
delimiter characters that indicate the start of a logical page section.
These can be changed from the default characters \: to two user-specified
characters. If only one character is entered, the second character remains
the default character ":". -f
type Specify the same as b
type except for footer. The default for logical page
footer is n (no lines numbered). -h
type Specify the same as b
type except for header. The default type
for logical page header is n (no lines numbered). -i
incr
Specify the increment value used to number logical page lines. The default
is 1. -l
num Specify
the number of blank lines to be considered as one. For example,
-l 2 results in only the second adjacent blank line
being numbered (if the appropriate h -a,
-b a or -f a option is set).
The default is 1. -n format
Specify the line numbering format. Recognised values are:
ln, left
justified, leading zeros suppressed; rn, right justified,
leading zeros suppressed;
rz, right
justified, leading zeros kept. The default format is
rn (right justified). -p Specify
that numbering should not be restarted at logical page delimiters.
-s sep Specify the characters used
in separating the line number and the corresponding text line. The default
sep is a tab. -v
startnum
Specify the initial value used to number logical page lines. The default is
1. -w width Specify the number of
characters to be used for the line number. The default
width is 6.
OPERANDS
The following operand is supported:
- file
- A pathname of a text file to be line-numbered.
STDIN
The standard input is a text file that is used if no file operand is given.
INPUT FILES
The input file named by the file operand is a text file.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of
nl :
LANG- Provide a default value for the internationalisation variables that are
unset or null. If
LANGis unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL- If set to a non-empty string value, override the values of all the other internationalisation variables.
LC_COLLATE- Determine the locale for the behaviour of ranges, equivalence classes and multi-character collating elements within regular expressions.
LC_CTYPE- Determine the locale for the interpretation of sequences of bytes of text
data as characters (for example, single- as opposed to multi-byte
characters in arguments and input files), the behaviour of character
classes within regular expressions, and for deciding which characters are
in character class graph (for the b
-t,-ft and-ht options). LC_MESSAGES- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
NLSPATH- Determine the location of message catalogues for the processing of LC_MESSAGES .
ASYNCHRONOUS EVENTS
Default.
STDOUT
The standard output is a text file in the following format:
"%s%s%s", <line
number>, <separator>, <input line> where <
line number > is
one of the following numeric formats:
- %6d
- when the rn format is used (the default; see
-n). - %06d
- when the rz format is used.
- %-6d
- when the ln(1) format is used.
- <empty>
- when line numbers are suppressed for a portion of the page; the < separator > is also suppressed.
In the preceding list, the number 6 is the default width; the
-w option can change this value.
STDERR
Used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The following exit values are returned:
CONSEQUENCES OF ERRORS
Default.
APPLICATION USAGE
In using the -d delim option, care should
be taken to escape characters that have special meaning to the command
interpreter.
EXAMPLES
The command:
nl -v 10 -i 10 -d \!+ file1
FUTURE DIRECTIONS
The intermingling of the file operand with the options is an obsolescent feature that will be removed from a future issue.
SEE ALSO
pr(1) .