summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/nl.1
blob: 0072221bef6c448024a3ddeabb26d43c203338e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions 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.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Copyright (c) 1995, Sun Microsystems, Inc.  All Rights Reserved.
.\" Portions Copyright (c) 1992, X/Open Company Limited  All Rights Reserved
.\"
.TH NL 1 "Mar 28, 1995"
.SH NAME
nl \- line numbering filter
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/nl\fR [\fB-p\fR] [\fB-b\fR [\fItype\fR]] [\fB-d\fR [\fIdelim\fR]] [\fB-f\fR [\fItype\fR]]
     [\fB-h\fR [\fItype\fR]] [\fB-i\fR [\fIincr\fR]] [\fB-l\fR [\fInum\fR]] [\fB-n\fR [\fIformat\fR]]
     [\fB-s\fR [\fIsep\fR]] [\fB-w\fR [\fIwidth\fR]] [\fB-v\fR [\fIstartnum\fR]] [\fIfile\fR]
.fi

.LP
.nf
\fB/usr/xpg4/bin/nl\fR [\fB-p\fR] [\fB-b\fR \fItype\fR] [\fB-d\fR \fIdelim\fR] [\fB-f\fR \fItype\fR]
     [\fB-h\fR \fItype\fR] [\fB-i\fR \fIincr\fR] [\fB-l\fR \fInum\fR] [\fB-n\fR \fIformat\fR] [\fB-s\fR \fIsep\fR]
     [\fB-w\fR \fIwidth\fR] [\fB-v\fR \fIstartnum\fR] [\fIfile\fR]
.fi

.SH DESCRIPTION
.sp
.LP
The \fBnl\fR utility reads lines from the named \fIfile\fR, or the standard
input if no \fIfile\fR is named, and reproduces the lines on the standard
output. Lines are numbered on the left in accordance with the command options
in effect.
.sp
.LP
\fBnl\fR views the text it reads in terms of logical pages. Line numbering is
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,
\fB-bt\fR (the default) numbers non-blank lines in the body section and does
not number any lines in the header and footer sections.
.sp
.LP
The start of logical page sections are signaled by input lines containing
nothing but the following delimiter character(s):
.sp

.sp
.TS
box;
c | c
l | l .
Line contents	Start Of
_
\e:\e:\e:	header
_
\e:\e:	body
_
\e:	footer
.TE

.sp
.LP
Unless optioned otherwise, \fBnl\fR assumes the text being read is in a single
logical page body.
.SH OPTIONS
.sp
.LP
Command options may appear in any order and may be intermingled with an
optional file name. Only one file may be named. The specified default is used
when the option is not entered on the command line. \fB/usr/xpg4/bin/nl\fR
options require option arguments.  A \fBSPACE\fR character \fBmay\fR separate
options from option arguments. \fB/usr/bin/nl\fR options  \fBmay\fR have option
arguments. If option-arguments of \fB/usr/bin/nl\fR options are not specified,
these options result in the default. The supported options are:
.sp
.ne 2
.na
\fB\fB-b\fR\fItype\fR\fR
.ad
.RS 14n
Specifies which logical page body lines are to be numbered. Recognized
\fItype\fRs and their meanings are:
.sp
.ne 2
.na
\fB\fBa\fR\fR
.ad
.RS 8n
number all lines
.RE

.sp
.ne 2
.na
\fB\fBt\fR\fR
.ad
.RS 8n
number all non-empty lines.
.RE

.sp
.ne 2
.na
\fB\fBn\fR\fR
.ad
.RS 8n
no line numbering
.RE

.sp
.ne 2
.na
\fB\fBp\fIexp\fR\fR\fR
.ad
.RS 8n
number only lines that contain the regular expression specified in \fIexp\fR.
See NOTES below.
.RE

Default \fItype\fR for logical page body is \fBt\fR (text lines numbered).
.RE

.sp
.ne 2
.na
\fB\fB-f\fR\fItype\fR\fR
.ad
.RS 14n
Same as \fB-b\fR\fItype\fR except for footer. Default \fItype\fR for logical
page footer is \fBn\fR (no lines numbered).
.RE

.sp
.ne 2
.na
\fB\fB-d\fR\fIdelim\fR\fR
.ad
.RS 14n
The two delimiter characters specifying the start of a logical page section may
be changed from the default characters (\e\|:\|) to two user-specified
characters. If only one character is entered, the second character remains the
default character (:). No space should appear between the \fB-d\fR and the
delimiter characters. To enter a backslash, use two backslashes.
.RE

.sp
.ne 2
.na
\fB\fB-h\fR\fItype\fR\fR
.ad
.RS 14n
Same as \fB-b\fR\fItype\fR except for header. Default \fItype\fR for logical
page header is \fBn\fR (no lines numbered).
.RE

.sp
.ne 2
.na
\fB\fB-i\fR\fIincr\fR\fR
.ad
.RS 14n
\fIincr\fR is the increment value used to number logical page lines. Default
\fIincr\fR is \fB1\fR.
.RE

.sp
.ne 2
.na
\fB\fB-l\fR\fInum\fR\fR
.ad
.RS 14n
\fInum\fR is the number of blank lines to be considered as one. For example,
\fB\(mil2\fR results in only the second adjacent blank being numbered (if the
appropriate \fB-ha\fR, \fB-ba\fR, and/or \fB-fa\fR option is set). Default
\fInum\fR is \fB1\fR.
.RE

.sp
.ne 2
.na
\fB\fB-n\fR\fIformat\fR\fR
.ad
.RS 14n
\fIformat\fR is the line numbering format. Recognized values are:
.sp
.ne 2
.na
\fB\fBln\fR\fR
.ad
.RS 6n
left justified, leading zeroes suppressed
.RE

.sp
.ne 2
.na
\fB\fBrn\fR\fR
.ad
.RS 6n
right justified, leading zeroes suppressed
.RE

.sp
.ne 2
.na
\fB\fBrz\fR\fR
.ad
.RS 6n
right justified, leading zeroes kept
.RE

Default \fIformat\fR is \fBrn\fR (right justified).
.RE

.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 14n
Do not restart numbering at logical page delimiters.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR\fIsep\fR\fR
.ad
.RS 14n
\fIsep\fR is the character(s) used in separating the line number and the
corresponding text line. Default \fIsep\fR is a \fBTAB\fR.
.RE

.sp
.ne 2
.na
\fB\fB-v\fR\fIstartnum\fR\fR
.ad
.RS 14n
\fIstartnum\fR is the initial value used to number logical page lines. Default
\fIstartnum\fR is \fB1\fR.
.RE

.sp
.ne 2
.na
\fB\fB-w\fR\fIwidth\fR\fR
.ad
.RS 14n
\fIwidth\fR is the number of characters to be used for the line number. Default
\fIwidth\fR is \fB6\fR.
.RE

.SH OPERANDS
.sp
.LP
The following operand is supported:
.sp
.ne 2
.na
\fB\fIfile\fR\fR
.ad
.RS 8n
A path name of a text file to be line-numbered.
.RE

.SH EXAMPLES
.LP
\fBExample 1 \fRAn example of the nl command
.sp
.LP
The command:

.sp
.in +2
.nf
example% \fBnl -v10 -i10 -d!+ filename1\fR
.fi
.in -2
.sp

.sp
.LP
will cause the first line of the page body to be numbered \fB10\fR, the second
line of the page body to be numbered \fB20\fR, the third \fB30\fR, and so
forth. The logical page delimiters are !+.

.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(7) for descriptions of the following environment variables
that affect the execution of \fBnl\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH FILES
.sp
.ne 2
.na
\fB\fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/CollTable\fR\fR
.ad
.sp .6
.RS 4n
Collation table generated by \fBlocaledef\fR
.RE

.sp
.ne 2
.na
\fB\fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/coll.so\fR\fR
.ad
.sp .6
.RS 4n
Shared object containing string transformation library routines
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.SS "/usr/xpg4/bin/nl"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Standard
.TE

.SH SEE ALSO
.sp
.LP
.BR pr (1),
.BR attributes (7),
.BR environ (7),
.BR regex (7),
.BR regexp (7),
.BR standards (7)
.SH NOTES
.sp
.LP
Internationalized Regular Expressions are used in the POSIX and "C" locales. In
other locales, Internationalized Regular Expressions are used if the following
two conditions are met:
.RS +4
.TP
.ie t \(bu
.el o
\fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/CollTable\fR is present.
.RE
.RS +4
.TP
.ie t \(bu
.el o
\fB/usr/lib/locale/\fIlocale\fR/LC_COLLATE/coll.so\fR is not present.
.RE
.sp
.LP
Otherwise, Simple Regular Expressions are used.
.sp
.LP
Internationalized Regular Expressions are explained on \fBregex\fR(7). Simple
Regular Expressions are explained on  \fBregexp\fR(7).