1nl(1)                            User Commands                           nl(1)
2
3
4

NAME

6       nl - line numbering filter
7

SYNOPSIS

9       /usr/bin/nl [-p] [-b [type]] [-d [delim]] [-f [type]]
10            [-h [type]] [-i [incr]] [-l [num]] [-n [format]]
11            [-s [sep]] [-w [width]] [-v [startnum]] [file]
12
13
14       /usr/xpg4/bin/nl [-p] [-b type] [-d delim] [-f type]
15            [-h type] [-i incr] [-l num] [-n format] [-s sep]
16            [-w width] [-v startnum] [file]
17
18

DESCRIPTION

20       The  nl  utility reads lines from the named file, or the standard input
21       if no file is named, and reproduces the lines on the  standard  output.
22       Lines  are  numbered on the left in accordance with the command options
23       in effect.
24
25
26       nl views the text it reads in terms of logical pages. Line numbering is
27       reset  at  the start of each logical page. A logical page consists of a
28       header, a body, and a footer section. Empty sections are valid. Differ‐
29       ent  line  numbering  options  are  independently available for header,
30       body, and footer. For example,  -bt  (the  default)  numbers  non-blank
31       lines  in  the body section and does not number any lines in the header
32       and footer sections.
33
34
35       The start of logical page sections are signaled by input lines contain‐
36       ing nothing but the following delimiter character(s):
37
38
39
40
41       ┌─────────────────────────────┬─────────────────────────────┐
42       │       Line contents         │          Start Of           │
43       ├─────────────────────────────┼─────────────────────────────┤
44       │\:\:\:                       │header                       │
45       ├─────────────────────────────┼─────────────────────────────┤
46       │\:\:                         │body                         │
47       ├─────────────────────────────┼─────────────────────────────┤
48       │\:                           │footer                       │
49       └─────────────────────────────┴─────────────────────────────┘
50
51
52       Unless  optioned otherwise, nl assumes the text being read is in a sin‐
53       gle logical page body.
54

OPTIONS

56       Command options may appear in any order and may be intermingled with an
57       optional  file  name. Only one file may be named. The specified default
58       is  used  when  the  option  is  not  entered  on  the  command   line.
59       /usr/xpg4/bin/nl  options  require option arguments.  A SPACE character
60       may separate options from option arguments.  /usr/bin/nl  options   may
61       have  option  arguments. If option-arguments of /usr/bin/nl options are
62       not specified, these options  result  in  the  default.  The  supported
63       options are:
64
65       -btype        Specifies  which  logical  page body lines are to be num‐
66                     bered. Recognized types and their meanings are:
67
68                     a       number all lines
69
70
71                     t       number all non-empty lines.
72
73
74                     n       no line numbering
75
76
77                     pexp    number  only  lines  that  contain  the   regular
78                             expression specified in exp. See NOTES below.
79
80                     Default  type for logical page body is t (text lines num‐
81                     bered).
82
83
84       -ftype        Same as -btype except for footer. Default type for  logi‐
85                     cal page footer is n (no lines numbered).
86
87
88       -ddelim       The  two  delimiter  characters specifying the start of a
89                     logical page section may  be  changed  from  the  default
90                     characters (\:) to two user-specified characters. If only
91                     one character is entered, the  second  character  remains
92                     the default character (:). No space should appear between
93                     the -d and the delimiter characters.  To  enter  a  back‐
94                     slash, use two backslashes.
95
96
97       -htype        Same  as -btype except for header. Default type for logi‐
98                     cal page header is n (no lines numbered).
99
100
101       -iincr        incr is the increment value used to number  logical  page
102                     lines. Default incr is 1.
103
104
105       -lnum         num is the number of blank lines to be considered as one.
106                     For example, −l2 results  in  only  the  second  adjacent
107                     blank being numbered (if the appropriate -ha, -ba, and/or
108                     -fa option is set). Default num is 1.
109
110
111       -nformat      format is the line numbering  format.  Recognized  values
112                     are:
113
114                     ln    left justified, leading zeroes suppressed
115
116
117                     rn    right justified, leading zeroes suppressed
118
119
120                     rz    right justified, leading zeroes kept
121
122                     Default format is rn (right justified).
123
124
125       -p            Do not restart numbering at logical page delimiters.
126
127
128       -ssep         sep  is the character(s) used in separating the line num‐
129                     ber and the corresponding text line.  Default  sep  is  a
130                     TAB.
131
132
133       -vstartnum    startnum is the initial value used to number logical page
134                     lines. Default startnum is 1.
135
136
137       -wwidth       width is the number of characters to be used for the line
138                     number. Default width is 6.
139
140

OPERANDS

142       The following operand is supported:
143
144       file    A path name of a text file to be line-numbered.
145
146

EXAMPLES

148       Example 1 An example of the nl command
149
150
151       The command:
152
153
154         example% nl -v10 -i10 -d!+ filename1
155
156
157
158
159       will  cause the first line of the page body to be numbered 10, the sec‐
160       ond line of the page body to be numbered  20,  the  third  30,  and  so
161       forth. The logical page delimiters are !+.
162
163

ENVIRONMENT VARIABLES

165       See  environ(5) for descriptions of the following environment variables
166       that affect the execution of nl: LANG,  LC_ALL,  LC_COLLATE,  LC_CTYPE,
167       LC_MESSAGES, and NLSPATH.
168

EXIT STATUS

170       The following exit values are returned:
171
172       0     Successful completion.
173
174
175       >0    An error occurred.
176
177

FILES

179       /usr/lib/locale/locale/LC_COLLATE/CollTable
180
181           Collation table generated by localedef
182
183
184       /usr/lib/locale/locale/LC_COLLATE/coll.so
185
186           Shared object containing string transformation library routines
187
188

ATTRIBUTES

190       See attributes(5) for descriptions of the following attributes:
191
192   /usr/bin/nl
193       ┌─────────────────────────────┬─────────────────────────────┐
194       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
195       ├─────────────────────────────┼─────────────────────────────┤
196       │Availability                 │SUNWesu                      │
197       └─────────────────────────────┴─────────────────────────────┘
198
199   /usr/xpg4/bin/nl
200       ┌─────────────────────────────┬─────────────────────────────┐
201       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
202       ├─────────────────────────────┼─────────────────────────────┤
203       │Availability                 │SUNWxcu4                     │
204       ├─────────────────────────────┼─────────────────────────────┤
205       │Interface Stability          │Standard                     │
206       └─────────────────────────────┴─────────────────────────────┘
207

SEE ALSO

209       pr(1), attributes(5), environ(5), regex(5), regexp(5), standards(5)
210

NOTES

212       Internationalized  Regular  Expressions  are  used in the POSIX and "C"
213       locales. In other locales, Internationalized  Regular  Expressions  are
214       used if the following two conditions are met:
215
216           o      /usr/lib/locale/locale/LC_COLLATE/CollTable is present.
217
218           o      /usr/lib/locale/locale/LC_COLLATE/coll.so is not present.
219
220
221       Otherwise, Simple Regular Expressions are used.
222
223
224       Internationalized Regular Expressions are explained on regex(5). Simple
225       Regular Expressions are explained on  regexp(5).
226
227
228
229SunOS 5.11                        28 Mar 1995                            nl(1)
Impressum