| Main index | Section 1 | 日本語 | Deutsch | Options |
The nl utility treats the text it reads in terms of logical pages. Unless specified otherwise, 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 sections.
The starts of logical page sections are signalled by input lines containing nothing but one of the following sequences of delimiter characters:
| Start of | |
\:\:\: | header |
\:\: | body |
\: | footer |
If the input does not contain any logical page section signalling directives, the text being read is assumed to consist of a single logical page body.
The following options are available:
| | |
| Specify the logical page body lines to be numbered. Recognized type arguments are: | |
| a | Number all lines. |
| t | Number only non-empty lines. |
| n | No line numbering. |
| pexpr | Number only those lines that contain the basic regular expression specified by expr. |
The default type for logical page body lines is t.
| | |
| Specify the delimiter characters used to indicate the start of a logical page section in the input file. At most two characters may be specified; if only one character is specified, the first character is replaced and the second character remains unchanged. The default delim characters are "\:". | |
| | |
|
Specify the same as
| |
| | |
|
Specify the same as
| |
| | |
| Specify the increment value used to number logical page lines. The default incr value is 1. | |
| | |
|
If numbering of all lines is specified for the current logical section
using the corresponding
| |
| | |
| Specify the line numbering output format. Recognized format arguments are: | |
| ln | Left justified. |
| rn | Right justified, leading zeros suppressed. |
| rz | Right justified, leading zeros kept. |
The default format is rn.
| | |
| Specify that line numbering should not be restarted at logical page delimiters. | |
| | |
| Specify the characters used in separating the line number and the corresponding text line. The default sep setting is a single tab character. | |
| | |
|
Specify the initial value used to number logical page lines; see also the
description of the
| |
| | |
| Specify the number of characters to be occupied by the line number; in case the width is insufficient to hold the line number, it will be truncated to its width least significant digits. The default width is 6. | |
$ echo -e "This is 00 simple text" | nl
1 This is
2 a simple text
Number all lines including blank ones, with right justified line numbers with leading zeroes, starting at 2, with increment of 2 and a custom multi-character separator:
$ echo -e "This s n 00xample" | nl -ba -n rz -i2 -s "->" -v2 000002->This 000004->is 000006->an 000008-> 000010-> 000012->example
Number lines matching regular expression for an i followed by either m or n
$ echo -e "This is simple text ith multiple ines" | nl -bp'i[mn]'
This is
1 a simple text
with multiple
2 lines
| NL (1) | July 24, 2022 |
| Main index | Section 1 | 日本語 | Deutsch | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
| “ | "I liken starting one's computing career with Unix, say as an undergraduate, to being born in East Africa. It is intolerably hot, your body is covered with lice and flies, you are malnourished and you suffer from numerous curable diseases. But, as far as young East Africans can tell, this is simply the natural condition and they live within it. By the time they find out differently, it is too late. They already think that the writing of shell scripts is a natural act." | ” |
| — Ken Pier, Xerox PARC | ||