Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cat(1)

pr(1)

nl(1)  —  Commands

OSF

NAME

nl − Numbers lines in a file

SYNOPSIS

nl [−b[type]] [−d[delimiter1delimiter2]] [−f[type]] [−h[type]]
     [−i[number]] [−l[number]] [−n[format]] [−p] [−s[separator]]
     [−v[number]] [−w[number]] [file]

The nl command reads file (standard input by default), numbers the lines in the input, and writes the numbered lines to standard output. 

FLAGS

Use the following flags to change the default settings.  Except for the -s flag, enter a flag without an argument to use its default value. 

-btypeSpecifies which body section lines to number.  The recognized types are as follows:

aNumbers all lines. 

tDoes not number blank lines (default). 

nDoes not number any lines. 

ppatternNumbers only those lines containing the specified pattern. 

-ddelimiter1delimiter2
Uses delimiter1 and delimiter2 as the delimiters for the start of a logical page section.  The default characters are \: (backslash followed by a colon).  You can specify two single-byte 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 (\\). 

-ftypeSpecifies which logical page footer lines to number.  The types recognized are the same as in -btype.  The default type is n (no lines numbered). 

-htypeSpecifies which logical page header lines to number.  The types recognized are the same as in -btype.  The default type is n (no lines numbered). 

-inumberIncrements logical page line numbers by number.  The default value of number is 1. 

-lnumberCounts number blank lines as 1.  For example, -l3 will only number the third adjacent blank.  The default value of number is 2.  This flag can only be used when the -b flag is used. 

-nformatSpecifies format as the line numbering format.  Recognized formats are as follows:

lnLeft justified, leading zeroes are suppressed. 

rnRight justified, leading zeroes are suppressed (default). 

rzRight justified, leading zeroes are kept. 

-pIgnores logical page delimiters (does not restart numbering). 

-s[separator]
Separates text from line numbers with the separator character.  The default value of separator is a tab character.  If you enter -s without an argument, there is no separation between the line number and its text. 

-vnumber
Sets the initial logical page line number to number (1 by default). 

-wnumber
Specifies number as the number of digits in the line number.  The default value of number is 6. 

DESCRIPTION

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 (sections can be empty).  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). 

Signal the start of logical page sections with lines in file that contain nothing but the following delimiter characters:

Line ContentsStart of

\:\:\:Header

\:\:Body

\:Footer

You can name only one file on the command line.  You can list the flags and the filename in any order. 

EXAMPLES

     1.To number only the nonblank lines, enter:

nl chap1

This displays a numbered listing of chap1, numbering only the nonblank lines in the body sections.  If chap1 contains no \:\:\ :, \:\ :, or \: delimiters, then the entire file is considered the body. 

     2.To number all lines, enter:

nl  -ba  chap1

This 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, enter:

nl  -i10  -nrz  -s::  -v10  -w4  chap1

This numbers the lines of chap1, starting with 10 (-v10) and counting by 10s (-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 following text:

A not-so-important note to remember:
 You can’t kill time without injuring eternity.

then the numbered listing is as follows:

0010::A not-so-important note to remember:
 0020::You can’t kill time without injuring eternity.

Note that the blank line was not numbered. To do this, use the -ba flag as shown in Example 2. 

RELATED INFORMATION

Commands:  cat(1), pr(1). 

OSF/1 User’s Guide. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026