NL(1POSIX) | POSIX Programmer's Manual | NL(1POSIX) |
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.
nl — line numbering filter
nl [-p] [-b type] [-d delim] [-f type] [-h type] [-i incr] [-l num] [-n format] [-s sep] [-v startnum] [-w width] [file]
The nl utility shall read lines from the named file or the standard input if no file is named and shall reproduce the lines to standard output. Lines shall be numbered on the left. Additional functionality may be provided in accordance with the command options in effect.
The nl utility views the text it reads in terms of logical pages. Line numbering shall be reset at the start of each logical page. A logical page consists of a header, a body, and a footer section. Empty sections are valid. Different line numbering options are independently available for header, body, and footer (for example, no numbering of header and footer lines while numbering blank lines only in the body).
The starts of logical page sections shall be signaled by input lines containing nothing but the following delimiter characters:
Line | Start of |
\:\:\: | Header |
\:\: | Body |
\: | Footer |
Unless otherwise specified, nl shall assume the text being read is in a single logical page body.
The nl utility shall conform to the Base Definitions volume of POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines. Only one file can be named.
The following options shall be supported:
The default type for logical page body shall be t (text lines numbered).
The following operand shall be supported:
The standard input shall be used if no file operand is specified, and shall be used if the file operand is '-' and the implementation treats the '-' as meaning standard input. Otherwise, the standard input shall not be used. See the INPUT FILES section.
The input file shall be a text file.
The following environment variables shall affect the execution of nl:
Default.
The standard output shall be a text file in the following format:
"%s%s%s", <line number>, <separator>, <input line>
where <line number> is one of the following numeric formats:
In the preceding list, the number 6 is the default width; the -w option can change this value.
The standard error shall be used only for diagnostic messages.
None.
None.
The following exit values shall be returned:
Default.
The following sections are informative.
In using the -d delim option, care should be taken to escape characters that have special meaning to the command interpreter.
The command:
nl -v 10 -i 10 -d \!+ file1
numbers file1 starting at line number 10 with an increment of 10. The logical page delimiter is "!+". Note that the '!' has to be escaped when using csh as a command interpreter because of its history substitution syntax. For ksh and sh the escape is not necessary, but does not do any harm.
None.
None.
pr
The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
2017 | IEEE/The Open Group |