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

NAME

6       nl - line numbering filter
7

SYNOPSIS

9       nl  [-p][-b  type][-d delim][-f type][-h type][-i incr][-l num][-n for‐
10       mat]
11               [-s sep][-v startnum][-w width][file]
12

DESCRIPTION

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

OPTIONS

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

OPERANDS

113       The following operand shall be supported:
114
115       file   A pathname of a text file to be line-numbered.
116
117

STDIN

119       The standard input is a text file that is used if no  file  operand  is
120       given.
121

INPUT FILES

123       The input file named by the file operand is a text file.
124

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

161       Default.
162

STDOUT

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

STDERR

186       The standard error shall be used only for diagnostic messages.
187

OUTPUT FILES

189       None.
190

EXTENDED DESCRIPTION

192       None.
193

EXIT STATUS

195       The following exit values shall be returned:
196
197        0     Successful completion.
198
199       >0     An error occurred.
200
201

CONSEQUENCES OF ERRORS

203       Default.
204
205       The following sections are informative.
206

APPLICATION USAGE

208       In using the -d delim option, care should be taken to escape characters
209       that have special meaning to the command interpreter.
210

EXAMPLES

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

RATIONALE

224       None.
225

FUTURE DIRECTIONS

227       None.
228

SEE ALSO

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