NL(1)

NAME
nl - line numbering filter

SYNOPSIS

nl [-htype] [-btype] [-ftype] [-vstart#] [-iincr] [-p] [-lnum] [-wwidth] [-nformat] [-ddelim] [file]

DESCRIPTION
The nl command prints a file, or, when no file argument is given, standard input, preceding lines with line numbers on the left.

Lines with special content are taken as page delimiters. Three parts of pages are distinguished: header, body and footer. Each part is started when a line consisting only of the following characters appears in input:

    Line contents | Start of
    \:\:\: | header
    \:\: | body
    \: | footer

Line numbers are reset each time a header begins. The start of the file is considered a body part until a line marking another part appears.

The following options alter the behavior of nl:

-btype
    Specifies which lines in a body part are numbered, where type is one of the following:

    a   Number all lines, unless otherwise specified by the -l option.

    t   Number all non-empty lines.

    n   Number no lines.

    pstring
        Number all lines that match the regular expression string. Regular expressions are as in ed(1); /usr/local/heirloom/usr/5bin/nl uses simple regular expressions, /usr/local/heirloom/usr/local/heirloom/usr/5bin/posix/nl and /usr/local/heirloom/usr/local/heirloom/usr/5bin/s42/nl use basic regular expressions.

    The default is t.

-ddelim
    Change the special characters that delimit parts of a page to the two characters in delim. If delim consists of only one character, the second character remains the default, `:'.

-ftype
    Specifies which lines in a footer part are numbered, where type has the format described for -b. The default is n.

-htype
    Specifies which lines in a header part are numbered, where type has the format described for -b. The default is n.

-iincr
    Line numbers are increased by incr, which defaults to 1.

-lnum
    For the -ba, -fa, and -ha options, specifies which line of adjacent blank lines is printed. The default is 1 (print all blank lines).

-nformat
    Sets the format of line numbers, where format is one of:

    ln  left-justified, preceded by blanks

    rn  right-justified, preceded by blanks

    rz  right-justified, preceded by zeros

    The default is rn.

-p  Line numbers are not reset at the start of each header when this option is present.

-ssep
    Sets the string that separates line number and line content in output, default is a tabulator.

-vstart#
    Each page is numbered starting at start#, which defaults to 1.

-wwidth
    Sets the width of line numbers. If a number has fewer digits than width, it is padded as described for the -n option; if it has more digits, only the last width digits are printed. The default width is 6.

The file argument can appear between options. For /usr/local/heirloom/usr/5bin/nl and /usr/local/heirloom/usr/local/heirloom/usr/5bin/s42/nl, option and option argument must not be separated; if an option is not immediately followed by its argument, the default value is used. /usr/local/heirloom/usr/local/heirloom/usr/5bin/posix/nl requires an option argument and accepts it regardless of space between option and argument.

ENVIRONMENT VARIABLES

LANG, LC_ALL
    See locale(7).

LC_COLLATE
    Affects the collation order for range expressions, equivalence classes, and collation symbols in basic regular expressions.

LC_CTYPE
    Determines the mapping of bytes to characters.

EXAMPLES

To number all lines in a file, effectively disabling header and footer recognition since no line can contain a second newline character and thus the condition is never met:

    nl -ba -d'
    ' file

Note that there is no white space other than the newline character between ' '.

To number all lines that are not empty and contain at least one non-blank character:

    nl -bp'[^      ]' file

The characters between [ ] are: a circumflex, a space, and a tabulator.

SEE ALSO
ed(1), pr(1), locale(7)

NOTES
Since the default width causes line numbers to be truncated if they consist of more than six digits, the -w option should be used to increase this value if higher numbers are to be expected.