1.\" $FreeBSD$ 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 January 26, 2005 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.Bk -words 40.Op Fl b Ar type 41.Ek 42.Bk -words 43.Op Fl d Ar delim 44.Ek 45.Bk -words 46.Op Fl f Ar type 47.Ek 48.Bk -words 49.Op Fl h Ar type 50.Ek 51.Bk -words 52.Op Fl i Ar incr 53.Ek 54.Bk -words 55.Op Fl l Ar num 56.Ek 57.Bk -words 58.Op Fl n Ar format 59.Ek 60.Bk -words 61.Op Fl s Ar sep 62.Ek 63.Bk -words 64.Op Fl v Ar startnum 65.Ek 66.Bk -words 67.Op Fl w Ar width 68.Ek 69.Op Ar file 70.Sh DESCRIPTION 71The 72.Nm 73utility reads lines from the named 74.Ar file 75or the standard input if the 76.Ar file 77argument is omitted, 78applies a configurable line numbering filter operation and writes the result 79to the standard output. 80.Pp 81The 82.Nm 83utility treats the text it reads in terms of logical pages. 84Unless specified otherwise, line numbering is reset at the start of each 85logical page. 86A logical page consists of a header, a body and a footer 87section; empty sections are valid. 88Different line numbering options are 89independently available for header, body and footer sections. 90.Pp 91The starts of logical page sections are signalled by input lines containing 92nothing but one of the following sequences of delimiter characters: 93.Pp 94.Bl -column "\e:\e:\e:" "Start of" -offset indent 95.Em "Line Start of" 96.It "\e:\e:\e: header" 97.It "\e:\e: body" 98.It "\e: footer" 99.El 100.Pp 101If the input does not contain any logical page section signalling directives, 102the text being read is assumed to consist of a single logical page body. 103.Pp 104The following options are available: 105.Bl -tag -width ".Fl v Ar startnum" 106.It Fl b Ar type 107Specify the logical page body lines to be numbered. 108Recognized 109.Ar type 110arguments are: 111.Bl -tag -width indent 112.It Cm a 113Number all lines. 114.It Cm t 115Number only non-empty lines. 116.It Cm n 117No line numbering. 118.It Cm p Ns Ar expr 119Number only those lines that contain the basic regular expression specified 120by 121.Ar expr . 122.El 123.Pp 124The default 125.Ar type 126for logical page body lines is 127.Cm t . 128.It Fl d Ar delim 129Specify the delimiter characters used to indicate the start of a logical 130page section in the input file. 131At most two characters may be specified; 132if only one character is specified, the first character is replaced and the 133second character remains unchanged. 134The default 135.Ar delim 136characters are 137.Dq Li \e: . 138.It Fl f Ar type 139Specify the same as 140.Fl b Ar type 141except for logical page footer lines. 142The default 143.Ar type 144for logical page footer lines is 145.Cm n . 146.It Fl h Ar type 147Specify the same as 148.Fl b Ar type 149except for logical page header lines. 150The default 151.Ar type 152for logical page header lines is 153.Cm n . 154.It Fl i Ar incr 155Specify the increment value used to number logical page lines. 156The default 157.Ar incr 158value is 1. 159.It Fl l Ar num 160If numbering of all lines is specified for the current logical section 161using the corresponding 162.Fl b Cm a , 163.Fl f Cm a 164or 165.Fl h Cm a 166option, 167specify the number of adjacent blank lines to be considered as one. 168For example, 169.Fl l 1702 results in only the second adjacent blank line being numbered. 171The default 172.Ar num 173value is 1. 174.It Fl n Ar format 175Specify the line numbering output format. 176Recognized 177.Ar format 178arguments are: 179.Bl -tag -width indent -compact 180.It Cm ln 181Left justified. 182.It Cm rn 183Right justified, leading zeros suppressed. 184.It Cm rz 185Right justified, leading zeros kept. 186.El 187.Pp 188The default 189.Ar format 190is 191.Cm rn . 192.It Fl p 193Specify that line numbering should not be restarted at logical page delimiters. 194.It Fl s Ar sep 195Specify the characters used in separating the line number and the corresponding 196text line. 197The default 198.Ar sep 199setting is a single tab character. 200.It Fl v Ar startnum 201Specify the initial value used to number logical page lines; see also the 202description of the 203.Fl p 204option. 205The default 206.Ar startnum 207value is 1. 208.It Fl w Ar width 209Specify the number of characters to be occupied by the line number; 210in case the 211.Ar width 212is insufficient to hold the line number, it will be truncated to its 213.Ar width 214least significant digits. 215The default 216.Ar width 217is 6. 218.El 219.Sh ENVIRONMENT 220The 221.Ev LANG , LC_ALL , LC_CTYPE 222and 223.Ev LC_COLLATE 224environment variables affect the execution of 225.Nm 226as described in 227.Xr environ 7 . 228.Sh EXIT STATUS 229.Ex -std 230.Sh SEE ALSO 231.Xr jot 1 , 232.Xr pr 1 233.Sh STANDARDS 234The 235.Nm 236utility conforms to 237.St -p1003.1-2001 . 238.Sh HISTORY 239The 240.Nm 241utility first appeared in 242.At V.2 . 243.Sh BUGS 244Input lines are limited to 245.Dv LINE_MAX 246(2048) bytes in length. 247