Name
nl [options
] [files
] — coreutils
Synopsis
/usr/bin
stdin stdout - file -- opt --help --version
nl
copies its files to standard output, prepending line numbers. 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: \:\:\:
(start of header), \:\:
(start of body), and \:
(start of footer). Each must appear on a line by itself. Then you can use additional options (see the manpage) to affect line-numbering in the headers and footers of your decorated file.
Get Linux Pocket Guide 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.