NL(1,C) AIX Commands Reference NL(1,C)
-------------------------------------------------------------------------------
nl
PURPOSE
Numbers lines in a file.
SYNTAX
+-------------+
+-------------- -bt -hn -fn --------------+ +---| -v1 -w6 |---+
nl ---| +----+ +-- -l2 --+ |---| | -nrn -d"\:" | |--->
| | -b | +----------------| |-+ | | | -i1 | |
+-| -h |---| one of +- -lnum -+ |-+ | +-------------+ |
^| -f | | +----------+ || | +-----------------+ |
|+----+ +-| a |---------------+| +-| -vnum -p |-+
| | t | | ^| -inum -dxx ||
| | n | | || -wnum ||
| | ppattern | | || -nformat ||
| +----------+ | |+-----------------+|
+---------------------------------------+ +-------------------+
+--- -stab ---+ +--------+
>---| +--- -s --+ |---| |---|
+-| |-+ +- file -+
+- -ssep -+
Note: This command does not have MBCS support.
DESCRIPTION
The nl command reads files (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 flags 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 (you can have empty sections). Unless you
use the -p flag, nl resets the line numbers at the start of each logical page.
You can set line numbering flags 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).
You can signal the start of logical page sections with lines in file that
contain nothing but the following delimiter characters:
Processed November 8, 1990 NL(1,C) 1
NL(1,C) AIX Commands Reference NL(1,C)
Line contents Start of
\:\:\: Header
\:\: Body
\: Footer
You can name only one file on the command line. You can list the flags and the
file name in any order.
FLAGS
All the parameters are set by default. (With the exception that the nl command
does not set header and footer lines by default.) Use the following flags to
change these default settings. Except for the -s flag, enter a flag without a
parameter to see its default value.
-btype Chooses which body section lines to number. The recognized types
are:
a Numbers all lines.
t Does not number blank lines (default).
n Does not number any lines.
ppattern Numbers only those lines containing the
specified pattern.
-dxx Uses xx as the delimiters for the start of a logical page section.
The default characters are \: (backslash followed by a colon).
You can specify two 1-byte ASCII characters or one 2-byte
character. If you enter only one 1-byte character after -d, the
second character remains the default (colon). If you want to use
a backslash as a delimiter, enter two backslashes (\\).
-ftype Chooses which logical page footer lines to number. The types
recognized are the same as in -btype. The default type is n (no
lines numbered).
-htype Chooses which logical page header lines to number. The types
recognized are the same as in -btype. The default type is n (no
lines numbered).
-inum Increments logical page line numbers by num. The default value of
num is 1.
-lnum Uses num as the number of blank lines to count as one. For
example, -l3 will only number the third adjacent blank. The
default value of num is 2. This flag can only be used in
documents where the -ba flag is used.
-n format Uses format as the line numbering format. Recognized formats are:
Processed November 8, 1990 NL(1,C) 2
NL(1,C) AIX Commands Reference NL(1,C)
ln Left justified, leading zeroes suppressed.
rn Right justified, leading zeroes suppressed (default).
rz Right justified, leading zeroes kept.
-p Does not restart numbering at logical page delimiters.
-s [sep] Separates the text from its line number by the sep characters.
The default value of sep is a tab character. If you enter -s
without a parameter, there is no separation between the line
number and its text.
-vnum Sets the initial logical page line number to num (1 by default).
-wnum Uses num as the number of characters in the line number. The
default value of num is 6.
EXAMPLES
1. To number only the nonblank lines:
nl chap1
This command displays a numbered listing of "chap1", numbering only the
nonblank lines in the body sections. If "chap1" contains no \:\:\+ :, \:\+
:, or \: delimiters, the entire file is considered the body.
2. To number all lines:
nl -ba chap1
This command numbers all the lines in the body sections, including blank
lines. This form of the nl command is adequate for most uses.
3. To specify a different line number format:
nl -i10 -nrz -s:: -v10 -w4 chap1
This command numbers the lines of "chap1" starting with line 10 ("-v10")
and counting by tens ("-i10"). It displays four digits for each number
("-w4"), including leading zeroes ("-nrz"). The line numbers are separated
from the text by two colons ("-s::").
For example, if "chap1" contains the text:
A not-so-important
note to remember:
You can't kill time
without injuring eternity.
then the numbered listing is:
Processed November 8, 1990 NL(1,C) 3
NL(1,C) AIX Commands Reference NL(1,C)
0010::A not-so-important
0020::note to remember:
0030::You can't kill time
0040::without injuring eternity.
The blank line is not numbered. To number all lines including blank ones,
use the "-ba" flag as shown in Example 2.
RELATED INFORMATION
See the following command: "pr."
See "Overview of International Character Support" in Managing the AIX Operating
System.
Processed November 8, 1990 NL(1,C) 4