UNIX/LINUX Command – nl


nl—Number lines of files


nl [–h header-style] [–b body-style] [–f footer-style] [–p] [–d cc] [–v start-number] [–i increment] [–l lines] [–s line-separator] [–w line-no-width] [–n {ln,rn,rz}] [–header-numbering=style] [–body-numbering=style] [–footer-numbering=style] [–first-page=number] [–page-increment=number] [–no-renumber] [–join-blank-lines=number] [–number-separator=string] [–number-width=number] [–number-format={ln,rn,rz}] [–section-delimiter=cc] [–help] [–version] [file…]


This manual page documents the GNU version of nl. nl copies each given file, or the standard input if none are given or when a file named – is given, to the standard output, with line numbers added to some or all of the lines.

nl considers its input to be composed of logical pages; by default, the line number is reset to 1 at the top of each logical page.

nl treats all of the input files as a single document; it does not reset line numbers or logical pages between files.

A logical page consists of three sections: header, body, and footer. Any of the sections can be empty. Each can be numbered in a different style from the others.

The beginnings of the sections of logical pages are indicated in the input file by a line containing nothing except one of the following delimiter strings:
\:\:\: start of header
\:\: start of body
\: start of footer

The two characters from which these strings are made can be changed with an option (see the next subsection), but the pattern and length of each string cannot be changed.

The section delimiter strings are replaced by an empty line on output. Any text that comes before the first section delimiter string in the input file is considered to be part of a body section, so a file that does not contain any section delimiter strings is considered to consist of a single body section.


Options Description
–h, –header-numbering=style See –footer-numbering.
–b, –body-numbering=style See –footer-numbering.
–f, –footer-numbering=style Select the numbering style for lines in the footer section of each logical page. When a line is not numbered, the current line number is not incremented, but the line number separator character is still prepended to the line. The styles are
a                 Number all lines
t                  Number only nonempty lines (default for body)
n                 Number no lines (default for header and footer)
pregexp     Number only lines that contain a match for regexp
–p, –no-renumber Do not reset the line number at the start of a logical page.
–v, –first-page=number Set the initial line number on each logical page to number (default 1).
–i, –page-increment=number Increment line numbers by number (default 1).
–l, –join-blank-lines=number Consider number (default 1) consecutive empty lines to be one logical line for numbering, and only number the last one. Where fewer than number consecutive empty lines occur, do not number them. An empty line is one that contains no characters, not even spaces or tabs.
–s, –number-separator=string Separate the line number from the text line in the output with string (default is a tab character).
–w, –number-width=number Use number characters for line numbers (default 6).
–n, –number-format={ln,rn,rz} Select the line numbering format:
ln            Left justified, no leading zeros
rn           Right justified, no leading zeros (default)
rz            Right justified, leading zeros
–d, –section-delimiter=cc Set the two delimiter characters that indicate the beginnings of logical page sections; if only one is given, the second remains :. To enter \, use \\.
–help Print a usage message and exit with a nonzero status.
–version Print version information on standard output, then exit.

Related Posts

UNIX/LINUX Command – rsync

UNIX/LINUX Command – rsync

NAME rsync – a fast, versatile, remote (and local) file-copying tool rsync Command SYNOPSIS Local: rsync [OPTION…] SRC… [DEST] Access via remote shell:Pull: rsync [OPTION…] [[email protected]]HOST:SRC… [DEST]Push: rsync [OPTION…] SRC… [[email protected]]HOST:DEST Access via rsync...

UNIX/LINUX Command – strip

UNIX/LINUX Command – strip

NAME strip—Discard symbols from object files. SYNOPSIS strip [ -Fbfdname|–target=bfdname ] [ -Ibfdname|–input-target=bfdname ] [ -Obfdname|–output-target=bfdname ] [-Rsectionname|–remove-section=sectionname ] [ -s|–strip-all ] [-S|-g|–strip-debug ][-x|–discard-all...

UNIX/LINUX Command – expand

UNIX/LINUX Command – expand

NAME expand—Convert tabs to spaces SYNOPSIS expand [–tab1[,tab2[,…]]] [–t tab1[,tab2[,…]]] [–i] [—tabs=tab1[,tab2[,…]]] [–initial] [–help] [–version] [file…] DESCRIPTION This manual page documents the GNU version of expand. expand writes the contents of each given...

UNIX/LINUX Command – uuencode

UNIX/LINUX Command – uuencode

NAME uuencode—Encode a binary fileuudecode—Decode a file created by uuencode SYNOPSIS uuencode [-m] [ file ] nameuudecode [-o outfile] [ file ]… DESCRIPTION uuencode and uudecode are used to transmit binary files over transmission mediums that do not support other...

Follow Us

Our Communities

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!



Submit a Comment

Your email address will not be published.

6 + eighteen =