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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
|
.\" $OpenBSD: pr.1,v 1.19 2009/02/08 17:15:10 jmc Exp $
.\"
.\" Copyright (c) 1991 Keith Muller.
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Keith Muller of the University of California, San Diego.
.\"
.\" 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.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
.\"
.\" from: @(#)pr.1 8.1 (Berkeley) 6/6/93
.\"
.Dd $Mdocdate: February 8 2009 $
.Dt PR 1
.Os
.Sh NAME
.Nm pr
.Nd print files
.Sh SYNOPSIS
.Nm pr
.Bk -words
.Op Ar +page
.Op Fl Ar column
.Op Fl adFfmrt
.Xo Oo
.Fl e
.Op Ar char
.Op Ar gap
.Oc
.Xc
.Op Fl h Ar header
.Xo Oo
.Fl i
.Op Ar char
.Op Ar gap
.Oc
.Xc
.Op Fl l Ar lines
.Xo Oo
.Fl n
.Op Ar char
.Op Ar width
.Oc
.Xc
.Op Fl o Ar offset
.Xo Oo
.Fl s
.Op Ar char
.Oc
.Xc
.Op Fl w Ar width
.Op -
.Op Ar file ...
.Ek
.Sh DESCRIPTION
The
.Nm pr
utility is a printing and pagination filter for text files.
When multiple input files are specified, each is read, formatted,
and written to standard output.
By default, the input is separated into 66-line pages, each with
.Bl -bullet -offset indent
.It
A 5-line header with the page number, date, time, and
the pathname of the file.
.It
A 5-line trailer consisting of blank lines.
.El
.Pp
Optionally, the trailer can be replaced by a
.Em <form-feed>
where this is more appropriate for the output device being used and
.Em <tab> Ns s
can be expanded to input relative
.Em <spaces> Ns s
or
.Em <space> Ns s
can be contracted to output relative
.Em <tab> Ns s .
The
.Nm pr
utility also interprets
.Em <form-feed> Ns s
in the input as the logical end of pages.
.Pp
When multiple column output is specified,
text columns are of equal width.
By default text columns are separated by at least one
.Em <blank> .
Input lines that do not fit into a text column are truncated, except
in the default single columns output mode.
.Pp
If standard output is associated with a terminal,
diagnostic messages are suppressed until the
.Nm pr
utility has completed processing.
.Pp
In the following option descriptions,
.Em column ,
.Em lines ,
.Em offset ,
.Em page ,
and
.Em width
are positive decimal integers and
.Em gap
is a non-negative decimal integer.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Ar \&+page
Begin output at page number
.Ar page
of the formatted input.
.It Fl Ar column
Produce output that is
.Ar column Ns s
wide (default is 1) that is written vertically
down each column in the order in which the text
is received from the input file.
The options
.Fl e
and
.Fl i
are assumed.
This option should not be used with
.Fl m .
When used with
.Fl t ,
the minimum number of lines is used to display the output.
.It Fl a
Modify the effect of the
.Fl Ar column
option so that the columns are filled across the page in a round-robin order
(e.g., when column is 2, the first input line heads column
1, the second heads column 2, the third is the second line
in column 1, etc.).
This option requires the use of the
.Fl Ar column
option.
.It Fl d
Produce output that is double spaced.
An extra
.Em <newline>
character is output following every
.Em <newline>
found in the input.
.It Xo Fl e
.Op Ar char
.Op Ar gap
.Xc
Expand each input
.Em <tab>
to the next greater column
position specified by the formula
.Ar n*gap+1 ,
where
.Em n
is an integer > 0.
If
.Ar gap
is zero or is omitted the default is 8.
All
.Em <tab>
characters in the input are expanded into the appropriate
number of
.Em <space> Ns s.
If any nondigit character,
.Ar char ,
is specified, it is used as the input tab character.
.It Fl F
Use a
.Em <form-feed>
character for new pages,
instead of the default behavior that uses a
sequence of
.Em <newline>
characters.
.It Fl f
Same as the
.Fl F
option.
.It Fl h Ar header
Use the string
.Ar header
to replace the
.Ar file name
in the header line.
.It Xo Fl i
.Op Ar char
.Op Ar gap
.Xc
In output, replace multiple
.Em <space> Ns s
with
.Em <tab> Ns s
whenever two or more
adjacent
.Em <space> Ns s
reach column positions
.Ar gap+1 ,
.Ar 2*gap+1 ,
etc.
If
.Ar gap
is zero or omitted, default
.Em <tab>
settings at every eighth column position
is used.
If any nondigit character,
.Ar char ,
is specified, it is used as the output
.Em <tab>
character.
.It Fl l Ar lines
Override the 66 line default and reset the page length to
.Ar lines .
If
.Ar lines
is not greater than the sum of both the header and trailer
depths (in lines), the
.Nm pr
utility suppresses output of both the header and trailer, as if the
.Fl t
option were in effect.
.It Fl m
Merge the contents of multiple files.
One line from each file specified by a file operand is
written side by side into text columns of equal fixed widths, in
terms of the number of column positions.
The number of text columns depends on the number of
file operands successfully opened.
The maximum number of files merged depends on page width and the
per process open file limit.
The options
.Fl e
and
.Fl i
are assumed.
.It Xo Fl n
.Op Ar char
.Op Ar width
.Xc
Provide
.Ar width
digit line numbering.
The default for
.Ar width ,
if not specified, is 5.
The number occupies the first
.Ar width
column positions of each text column or each line of
.Fl m
output.
If
.Ar char
(any nondigit character) is given, it is appended to the line number to
separate it from whatever follows.
The default for
.Ar char
is a
.Em <tab> .
Line numbers longer than
.Ar width
columns are truncated.
.It Fl o Ar offset
Each line of output is preceded by
.Ar offset
.Em <spaces> Ns s.
If the
.Fl o
option is not specified, the default is zero.
The space taken is in addition to the output line width.
.It Fl r
Write no diagnostic reports on failure to open a file.
.It Fl s Op Ar char
Separate text columns by the single character
.Ar char
instead of by the appropriate number of
.Em <space> Ns s
(default for
.Ar char
is the
.Em <tab>
character).
.It Fl t
Print neither the five-line identifying
header nor the five-line trailer usually supplied for each page.
Quit printing after the last line of each file without spacing to the
end of the page.
.It Fl w Ar width
Set the width of the line to
.Ar width
column positions for multiple text-column output only.
If the
.Fl w
option is not specified and the
.Fl s
option is not specified, the default width is 72.
If the
.Fl w
option is not specified and the
.Fl s
option is specified, the default width is 512.
.It Ar file
A pathname of a file to be printed.
If no
.Ar file
operands are specified, or if a
.Ar file
operand is
.Dq - ,
the standard input is used.
The standard input is used only if no
.Ar file
operands are specified, or if a
.Ar file
operand is
.Dq - .
.El
.Pp
The
.Fl s
option does not allow the option letter to be separated from its
argument, and the options
.Fl e ,
.Fl i ,
and
.Fl n
require that both arguments, if present, not be separated from the option
letter.
.Sh ERRORS
If
.Nm pr
receives an interrupt while printing to a terminal, it
flushes all accumulated error messages to the screen before
terminating.
.Pp
The
.Nm pr
utility exits 0 on success, and 1 if an error occurs.
.Pp
Error messages are written to standard error during the printing
process (if output is redirected) or after all successful
file printing is complete (when printing to a terminal).
.Sh NOTES
The interpretation of
.Em <form-feed> Ns s
in the input stream is that they are special
.Em <newline> Ns s
which have the side effect of causing a page break.
While this works
correctly for all cases, strict interpretation also implies that the
common convention of placing a
.Em <form-feed>
on a line by itself is actually interpreted as a blank line, page break,
blank line.
.Sh RESTRICTIONS
The
.Nm pr
utility is intended to paginate input containing basic
.Xr ascii 7
text formatting and input streams containing non-printing
.Em <control-characters> ,
.Em <escape-sequences>
or long lines may result in formatting errors.
.Pp
The
.Nm pr
utility does not currently understand over-printing using
.Em <back-space>
or
.Em <return>
characters, and except in the case of unmodified single-column output,
use of these characters will cause formatting errors.
.Sh SEE ALSO
.Xr cat 1 ,
.Xr more 1 ,
.Xr ascii 7
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2008
specification.
.Pp
.St -p1003.1-2008
is relatively silent concerning the
handling of input characters beyond the behavior dictated by the
.Nm pr
required command
options.
.Sh HISTORY
A
.Nm
command appeared in
.At v1 .
.Sh BUGS
The lack of a line wrapping option, and the specification that truncation
does not apply to single-column output frequently results in formatting
errors when input lines are longer than actual line width of the output device.
.Pp
The default width of 72 is archaic and non-obvious since it is normally
ignored in the default single column mode.
Using the
.Fl m
option with one column provides a way to truncate single column output but
there's no way to wrap long lines to a fixed line width.
.Pp
The default of
.Em <tab>
for the separator for the
.Fl n
and
.Fl s
options often results in lines apparently wider than expected.
|