1NL(1P)                     POSIX Programmer's Manual                    NL(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       nl - line numbering filter
13

SYNOPSIS

15       nl [-p][-b type][-d delim][-f type][-h type][-i incr][-l  num][-n  for‐
16       mat]
17               [-s sep][-v startnum][-w width][file]
18

DESCRIPTION

20       The  nl  utility  shall  read lines from the named file or the standard
21       input if no file is named and shall reproduce  the  lines  to  standard
22       output.  Lines  shall be numbered on the left. Additional functionality
23       may be provided in accordance with the command options in effect.
24
25       The nl utility views the text it reads in terms of logical pages.  Line
26       numbering  shall  be reset at the start of each logical page. A logical
27       page consists of a header, a body, and a footer section. Empty sections
28       are valid. Different line numbering options are independently available
29       for header, body, and footer (for example, no numbering of  header  and
30       footer lines while numbering blank lines only in the body).
31
32       The  starts  of  logical page sections shall be signaled by input lines
33       containing nothing but the following delimiter characters:
34
35                                  Line     Start of
36                                  \:\:\:   Header
37                                  \:\:     Body
38                                  \:       Footer
39
40       Unless otherwise specified, nl shall assume the text being read is in a
41       single logical page body.
42

OPTIONS

44       The  nl  utility  shall  conform  to  the  Base  Definitions  volume of
45       IEEE Std 1003.1-2001, Section 12.2, Utility  Syntax  Guidelines.   Only
46       one file can be named.
47
48       The following options shall be supported:
49
50       -b  type
51              Specify  which logical page body lines shall be numbered. Recog‐
52              nized types and their meaning are:
53
54       a
55              Number all lines.
56
57       t
58              Number only non-empty lines.
59
60       n
61              No line numbering.
62
63       pstring
64              Number only lines that  contain  the  basic  regular  expression
65              specified in string.
66
67
68       The  default  type  for  logical  page body shall be t (text lines num‐
69       bered).
70
71       -d  delim
72              Specify the delimiter characters that indicate the  start  of  a
73              logical  page  section.  These  can  be changed from the default
74              characters "\:" to two user-specified characters.  If  only  one
75              character  is  entered,  the  second  character shall remain the
76              default character ':' .
77
78       -f  type
79              Specify the same as b type except for footer.  The  default  for
80              logical page footer shall be n (no lines numbered).
81
82       -h  type
83              Specify  the  same as b type except for header. The default type
84              for logical page header shall be n (no lines numbered).
85
86       -i  incr
87              Specify the increment value used to number logical  page  lines.
88              The default shall be 1.
89
90       -l  num
91              Specify  the  number of blank lines to be considered as one. For
92              example, -l 2 results in only the  second  adjacent  blank  line
93              being numbered (if the appropriate -h a, -b a, or -f a option is
94              set). The default shall be 1.
95
96       -n  format
97              Specify the line numbering format. Recognized  values  are:  ln,
98              left  justified,  leading zeros suppressed; rn, right justified,
99              leading zeros suppressed; rz,  right  justified,  leading  zeros
100              kept. The default format shall be rn (right justified).
101
102       -p     Specify  that  numbering should not be restarted at logical page
103              delimiters.
104
105       -s  sep
106              Specify the characters used in separating the  line  number  and
107              the corresponding text line. The default sep shall be a <tab>.
108
109       -v  startnum
110              Specify the initial value used to number logical page lines. The
111              default shall be 1.
112
113       -w  width
114              Specify the number of characters to be used for the line number.
115              The default width shall be 6.
116
117

OPERANDS

119       The following operand shall be supported:
120
121       file   A pathname of a text file to be line-numbered.
122
123

STDIN

125       The  standard  input  is a text file that is used if no file operand is
126       given.
127

INPUT FILES

129       The input file named by the file operand is a text file.
130

ENVIRONMENT VARIABLES

132       The following environment variables shall affect the execution of nl:
133
134       LANG   Provide a default value for the  internationalization  variables
135              that  are  unset  or  null.  (See the Base Definitions volume of
136              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
137              ables  for the precedence of internationalization variables used
138              to determine the values of locale categories.)
139
140       LC_ALL If set to a non-empty string value, override the values  of  all
141              the other internationalization variables.
142
143       LC_COLLATE
144
145              Determine  the  locale  for  the behavior of ranges, equivalence
146              classes, and multi-character collating elements  within  regular
147              expressions.
148
149       LC_CTYPE
150              Determine  the  locale  for  the  interpretation of sequences of
151              bytes of text data as characters (for  example,  single-byte  as
152              opposed  to multi-byte characters in arguments and input files),
153              the behavior of character classes  within  regular  expressions,
154              and  for  deciding which characters are in character class graph
155              (for the -b t, -f t, and -h t options).
156
157       LC_MESSAGES
158              Determine the locale that should be used to  affect  the  format
159              and contents of diagnostic messages written to standard error.
160
161       NLSPATH
162              Determine the location of message catalogs for the processing of
163              LC_MESSAGES .
164
165

ASYNCHRONOUS EVENTS

167       Default.
168

STDOUT

170       The standard output shall be a text file in the following format:
171
172
173              "%s%s%s", <line number>, <separator>, <input line>
174
175       where <line number> is one of the following numeric formats:
176
177       %6d    When the rn format is used (the default; see -n).
178
179       %06d   When the rz format is used.
180
181       %-6d   When the ln format is used.
182
183       <empty>
184              When line numbers are suppressed for a portion of the page;  the
185              <separator> is also suppressed.
186
187
188       In the preceding list, the number 6 is the default width; the -w option
189       can change this value.
190

STDERR

192       The standard error shall be used only for diagnostic messages.
193

OUTPUT FILES

195       None.
196

EXTENDED DESCRIPTION

198       None.
199

EXIT STATUS

201       The following exit values shall be returned:
202
203        0     Successful completion.
204
205       >0     An error occurred.
206
207

CONSEQUENCES OF ERRORS

209       Default.
210
211       The following sections are informative.
212

APPLICATION USAGE

214       In using the -d delim option, care should be taken to escape characters
215       that have special meaning to the command interpreter.
216

EXAMPLES

218       The command:
219
220
221              nl -v 10 -i 10 -d \!+ file1
222
223       numbers  file1  starting at line number 10 with an increment of 10. The
224       logical page delimiter is "!+" . Note that the '!' has  to  be  escaped
225       when  using csh as a command interpreter because of its history substi‐
226       tution syntax. For ksh and sh the escape is not necessary, but does not
227       do any harm.
228

RATIONALE

230       None.
231

FUTURE DIRECTIONS

233       None.
234

SEE ALSO

236       pr
237
239       Portions  of  this text are reprinted and reproduced in electronic form
240       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
241       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
242       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
243       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
244       event of any discrepancy between this version and the original IEEE and
245       The  Open Group Standard, the original IEEE and The Open Group Standard
246       is the referee document. The original Standard can be  obtained  online
247       at http://www.opengroup.org/unix/online.html .
248
249
250
251IEEE/The Open Group                  2003                               NL(1P)
Impressum