xref: /netbsd-src/usr.bin/nl/nl.1 (revision 2626dec52e911d39cb7a1ec4c36165469cc869b8)
1.\"	$NetBSD: nl.1,v 1.16 2013/09/24 22:08:06 wiz Exp $
2.\"
3.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Klaus Klein.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd May 1, 2013
31.Dt NL 1
32.Os
33.Sh NAME
34.Nm nl
35.Nd line numbering filter
36.Sh SYNOPSIS
37.Nm
38.Op Fl p
39.Op Fl b Ar type
40.Op Fl d Ar delim
41.Op Fl f Ar type
42.Op Fl h Ar type
43.Op Fl i Ar incr
44.Op Fl l Ar num
45.Op Fl n Ar format
46.Op Fl s Ar sep
47.Op Fl v Ar startnum
48.Op Fl w Ar width
49.Op Ar file
50.Sh DESCRIPTION
51The
52.Nm
53utility reads lines from the named
54.Ar file ,
55applies a configurable line numbering filter operation,
56and writes the result to the standard output.
57If
58.Ar file
59is a single dash
60.Pq Sq \&-
61or absent,
62.Nm
63reads from the standard input.
64.Pp
65The
66.Nm
67utility treats the text it reads in terms of logical pages.
68Unless specified otherwise, line numbering is reset at the start of each
69logical page.
70A logical page consists of a header, a body and a footer section; empty
71sections are valid.
72Different line numbering options are independently available for header,
73body and footer sections.
74.Pp
75The starts of logical page sections are signaled by input lines containing
76nothing but one of the following sequences of delimiter characters:
77.Bl -column "\e:\e:\e: " "header " -offset indent
78.It Em "Line" Ta Em "Start of"
79.It \e:\e:\e:	header
80.It \e:\e:	body
81.It \e:	footer
82.El
83.Pp
84If the input does not contain any logical page section signaling directives,
85the text being read is assumed to consist of a single logical page body.
86.Pp
87The following options are available:
88.Bl -tag -width indent
89.It Fl b Ar type
90Specify the logical page body lines to be numbered.
91Recognized
92.Ar type
93arguments are:
94.Bl -tag -width pstringXX
95.It a
96Number all lines.
97.It t
98Number only non-empty lines.
99.It n
100No line numbering.
101.It p Ns Ar expr
102Number only those lines that contain the basic regular expression specified
103by
104.Ar expr .
105.El
106.Pp
107The default
108.Ar type
109for logical page body lines is t.
110.It Fl d Ar delim
111Specify the delimiter characters used to indicate the start of a logical
112page section in the input file.
113At most two characters may be specified; if only one character is specified,
114the first character is replaced and the second character remains unchanged.
115The default
116.Ar delim
117characters are ``\e:''.
118.It Fl f Ar type
119Specify the same as
120.Fl b Ar type
121except for logical page footer lines.
122The default
123.Ar type
124for logical page footer lines is n.
125.It Fl h Ar type
126Specify the same as
127.Fl b Ar type
128except for logical page header lines.
129The default
130.Ar type
131for logical page header lines is n.
132.It Fl i Ar incr
133Specify the increment value used to number logical page lines.
134The default
135.Ar incr
136value is 1.
137.It Fl l Ar num
138If numbering of all lines is specified for the current logical section
139using the corresponding
140.Fl b
141a,
142.Fl f
143a
144or
145.Fl h
146a
147option,
148specify the number of adjacent blank lines to be considered as one.
149For example,
150.Fl l
1512 results in only the second adjacent blank line being numbered.
152The default
153.Ar num
154value is 1.
155.It Fl n Ar format
156Specify the line numbering output format.
157Recognized
158.Ar format
159arguments are:
160.Pp
161.Bl -tag -width lnXX -compact -offset indent
162.It ln
163Left justified.
164.It rn
165Right justified, leading zeros suppressed.
166.It rz
167Right justified, leading zeros kept.
168.El
169.Pp
170The default
171.Ar format
172is rn.
173.It Fl p
174Specify that line numbering should not be restarted at logical page delimiters.
175.It Fl s Ar sep
176Specify the characters used in separating the line number and the corresponding
177text line.
178The default
179.Ar sep
180setting is a single tab character.
181.It Fl v Ar startnum
182Specify the initial value used to number logical page lines; see also the
183description of the
184.Fl p
185option.
186The default
187.Ar startnum
188value is 1.
189.It Fl w Ar width
190Specify the number of characters to be occupied by the line number;
191if the
192.Ar width
193is insufficient to hold the line number, it will be truncated to its
194.Ar width
195least significant digits.
196The default
197.Ar width
198is 6.
199.El
200.Sh EXIT STATUS
201.Ex -std
202.Sh SEE ALSO
203.Xr pr 1
204.Sh STANDARDS
205The
206.Nm
207utility is compliant with the
208.St -xpg4.2
209specification.
210.Sh HISTORY
211The
212.Nm
213utility first appeared in
214.At V.2 .
215