UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: niceChapter 2
UNIX Commands
Next: Reference: nm
 

nl

nl [options] [file]

Number the lines of file in logical page segments. Numbering resets to 1 at the start of each page.

Options

-btype

Number lines according to type. Values are:

aAll lines.
nNo lines.
t

Text lines only (the default).

p"exp"

Lines containing exp only.

-dxy

Use characters xy to delimit logical pages (default is \:).

-ftype

Like -b but number footer (default type is n).

-htype

Like -b but number header (default type is n).

-in

Increment each line number by n (default is 1).

-ln

Count n consecutive blank lines as one line.

-nformat

Set line number format. Values are:

ln

Left justify, omit leading zeros.

rn

Right justify, omit leading zeros (default).

rz

Right justify.

-p

Do not reset numbering at start of pages.

-sc

Separate text from line number with character(s) c (default is a tab).

-vn

Number each page starting at n (default is 1).

-wn

Use n columns to show line number (default is 6).

Examples

List the current directory, numbering files as 1), 2), etc.:

ls | nl -w3 -s')  '

Number C source code and save it:

nl prog.c > print_prog

Number only lines that begin with #include:

nl -bp"^#include" prog.c


Previous: Reference: niceUNIX in a Nutshell: System V EditionNext: Reference: nm
Reference: niceBook IndexReference: nm

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System