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