Name
nl — stdin stdout - file -- opt --help --version
Synopsis
nl [options
] [files
]
nl
copies its files to
standard output, prepending line numbers.
$ nl myfile 1 Once upon a time, there was 2 a little operating system named 3 Linux, which everybody loved.
It’s more flexible than cat
with its -n
and -b
options, providing an almost bizarre
amount of control over the numbering. nl
can be used in two ways: on ordinary
text files, and on specially marked-up text files with predefined
headers and footers.
Useful options
|
Prepend numbers to
all lines ( |
|
Begin numbering with
integer |
|
Increment the number
by |
|
Format numbers as
left-justified ( |
|
Force the width of
the number to be |
|
Insert string
|
Additionally, nl
has the
wacky ability to divide text files into virtual pages, each with a
header, body, and footer with different numbering schemes. For this
to work, however, you must insert nl
-specific delimiter strings into the
file, such as \:\:\:
(start of
header), \:\:
(start of body), and
\:
(start of footer). Each must appear on a line by itself. Then ...
Get Linux Pocket Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.