summaryrefslogtreecommitdiffstats
path: root/usr.bin/nl/nl.1
blob: 8ea7705ea5ef4fecd749f65fe77c13f8aafcf14d (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
.\" $FreeBSD$
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Klaus Klein.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"        This product includes software developed by the NetBSD
.\"        Foundation, Inc. and its contributors.
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
.\"    contributors may be used to endorse or promote products derived
.\"    from this software without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd July 13, 2004
.Dt NL 1
.Os
.Sh NAME
.Nm nl
.Nd line numbering filter
.Sh SYNOPSIS
.Nm
.Op Fl p
.Bk -words
.Op Fl b Ar type
.Ek
.Bk -words
.Op Fl d Ar delim
.Ek
.Bk -words
.Op Fl f Ar type
.Ek
.Bk -words
.Op Fl h Ar type
.Ek
.Bk -words
.Op Fl i Ar incr
.Ek
.Bk -words
.Op Fl l Ar num
.Ek
.Bk -words
.Op Fl n Ar format
.Ek
.Bk -words
.Op Fl s Ar sep
.Ek
.Bk -words
.Op Fl v Ar startnum
.Ek
.Bk -words
.Op Fl w Ar width
.Ek
.Op Ar file
.Sh DESCRIPTION
The
.Nm
utility reads lines from the named
.Ar file
or the standard input if the
.Ar file
argument is ommitted,
applies a configurable line numbering filter operation and writes the result
to the standard output.
.Pp
The
.Nm
utility treats the text it reads in terms of logical pages.
Unless specified otherwise, 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 sections.
.Pp
The starts of logical page sections are signalled by input lines containing
nothing but one of the following sequences of delimiter characters:
.Pp
.Bl -column "\e:\e:\e:" "Start of" -offset indent
.Em "Line	Start of"
.It "\e:\e:\e:	header"
.It "\e:\e:	body"
.It "\e:	footer"
.El
.Pp
If the input does not contain any logical page section signalling directives,
the text being read is assumed to consist of a single logical page body.
.Pp
The following options are available:
.Bl -tag -width ".Fl v Ar startnum"
.It Fl b Ar type
Specify the logical page body lines to be numbered.
Recognized
.Ar type
arguments are:
.Bl -tag -width indent
.It Cm a
Number all lines.
.It Cm t
Number only non-empty lines.
.It Cm n
No line numbering.
.It Cm p Ns Ar expr
Number only those lines that contain the basic regular expression specified
by
.Ar expr .
.El
.Pp
The default
.Ar type
for logical page body lines is
.Cm t .
.It Fl d Ar delim
Specify the delimiter characters used to indicate the start of a logical
page section in the input file.
At most two characters may be specified;
if only one character is specified, the first character is replaced and the
second character remains unchanged.
The default
.Ar delim
characters are
.Dq Li \e: .
.It Fl f Ar type
Specify the same as
.Fl b Ar type
except for logical page footer lines.
The default
.Ar type
for logical page footer lines is
.Cm n .
.It Fl h Ar type
Specify the same as
.Fl b Ar type
except for logical page header lines.
The default
.Ar type
for logical page header lines is
.Cm n .
.It Fl i Ar incr
Specify the increment value used to number logical page lines.
The default
.Ar incr
value is 1.
.It Fl l Ar num
If numbering of all lines is specified for the current logical section
using the corresponding
.Fl b Cm a ,
.Fl f Cm a
or
.Fl h Cm a
option,
specify the number of adjacent blank lines to be considered as one.
For example,
.Fl l
2 results in only the second adjacent blank line being numbered.
The default
.Ar num
value is 1.
.It Fl n Ar format
Specify the line numbering output format.
Recognized
.Ar format
arguments are:
.Bl -tag -width indent -compact
.It Cm ln
Left justified.
.It Cm rn
Right justified, leading zeros suppressed.
.It Cm rz
Right justified, leading zeros kept.
.El
.Pp
The default
.Ar format
is
.Cm rn .
.It Fl p
Specify that line numbering should not be restarted at logical page delimiters.
.It Fl s Ar sep
Specify the characters used in separating the line number and the corresponding
text line.
The default
.Ar sep
setting is a single tab character.
.It Fl v Ar startnum
Specify the initial value used to number logical page lines; see also the
description of the
.Fl p
option.
The default
.Ar startnum
value is 1.
.It Fl w Ar width
Specify the number of characters to be occupied by the line number;
in case the
.Ar width
is insufficient to hold the line number, it will be truncated to its
.Ar width
least significant digits.
The default
.Ar width
is 6.
.El
.Sh ENVIRONMENT
The
.Ev LANG , LC_ALL , LC_CTYPE
and
.Ev LC_COLLATE
environment variables affect the execution of
.Nm
as described in
.Xr environ 7 .
.Sh DIAGNOSTICS
.Ex -std
.Sh SEE ALSO
.Xr jot 1 ,
.Xr pr 1
.Sh STANDARDS
The
.Nm
utility conforms to
.St -p1003.1-2001 .
.Sh HISTORY
The
.Nm
utility first appeared in
.At V.2 .
OpenPOWER on IntegriCloud