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
|
.\" $OpenBSD: nl.1,v 1.6 2014/03/16 17:49:09 tedu Exp $
.\" $NetBSD: nl.1,v 1.14 2013/09/09 09:02:25 wiz Exp $
.\"
.\" 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.
.\"
.\" 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 $Mdocdate: March 16 2014 $
.Dt NL 1
.Os
.Sh NAME
.Nm nl
.Nd line numbering filter
.Sh SYNOPSIS
.Nm
.Op Fl p
.Op Fl b Ar type
.Op Fl d Ar delim
.Op Fl f Ar type
.Op Fl h Ar type
.Op Fl i Ar incr
.Op Fl l Ar num
.Op Fl n Ar format
.Op Fl s Ar sep
.Op Fl v Ar startnum
.Op Fl w Ar width
.Op Ar file
.Sh DESCRIPTION
The
.Nm
utility reads lines from the named
.Ar file ,
applies a configurable line numbering filter operation,
and writes the result to the standard output.
If
.Ar file
is a single dash
.Pq Sq \&-
or absent,
.Nm
reads from the standard input.
.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 signaled by input lines containing
nothing but one of the following sequences of delimiter characters:
.Bl -column "\e:\e:\e: " "header " -offset indent
.It Em "Line" Ta Em "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 signaling directives,
the text being read is assumed to consist of a single logical page body.
.Pp
The following options are available:
.Bl -tag -width indent
.It Fl b Ar type
Specify the logical page body lines to be numbered.
Recognized
.Ar type
arguments are:
.Bl -tag -width pstringXX
.It a
Number all lines.
.It t
Number only non-empty lines.
.It n
No line numbering.
.It 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 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 ``\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 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 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
a,
.Fl f
a
or
.Fl h
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:
.Pp
.Bl -tag -width lnXX -compact -offset indent
.It ln
Left justified.
.It rn
Right justified, leading zeros suppressed.
.It rz
Right justified, leading zeros kept.
.El
.Pp
The default
.Ar format
is 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;
if 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 EXIT STATUS
.Ex -std
.Sh SEE ALSO
.Xr pr 1
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -xpg4.2
specification.
.Sh HISTORY
The
.Nm
utility first appeared in
.At V.2 .
It was added to the
.Ox 5.5
release.
|