xref: /netbsd-src/usr.bin/pr/pr.1 (revision 450d651e78f3bef1a72186d80d4dceca0abbe06c)
1.\"	$NetBSD: pr.1,v 1.24 2019/09/01 18:31:37 sevan Exp $
2.\"
3.\" Copyright (c) 1991 Keith Muller.
4.\" Copyright (c) 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\" Copyright (c) 1994-1995, 1997, 1999-2003, 2009, 2012
7.\"	The NetBSD Foundation, Inc.
8.\"
9.\" This code is derived from software contributed to Berkeley by
10.\" Keith Muller of the University of California, San Diego.
11.\"
12.\" Redistribution and use in source and binary forms, with or without
13.\" modification, are permitted provided that the following conditions
14.\" are met:
15.\" 1. Redistributions of source code must retain the above copyright
16.\"    notice, this list of conditions and the following disclaimer.
17.\" 2. Redistributions in binary form must reproduce the above copyright
18.\"    notice, this list of conditions and the following disclaimer in the
19.\"    documentation and/or other materials provided with the distribution.
20.\" 3. Neither the name of the University nor the names of its contributors
21.\"    may be used to endorse or promote products derived from this software
22.\"    without specific prior written permission.
23.\"
24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE.
35.\"
36.\"     from: @(#)pr.1	8.1 (Berkeley) 6/6/93
37.\"
38.Dd September 1, 2019
39.Dt PR 1
40.Os
41.Sh NAME
42.Nm pr
43.Nd print files
44.Sh SYNOPSIS
45.Nm
46.Op Ar \&+page
47.Op Fl Ar column
48.Op Fl adFfmprt
49.Oo
50.Fl e Ns Oo Ar char Oc Ns Op Ar gap
51.Oc
52.Op Fl h Ar header
53.Oo
54.Fl i Ns Oo Ar char Oc Ns Op Ar gap
55.Oc
56.Op Fl l Ar lines
57.Oo
58.Fl n Ns Oo Ar char Oc Ns Op Ar width
59.Oc
60.Op Fl o Ar offset
61.Oo
62.Fl s Ns Op Ar char
63.Oc
64.Op Fl T Ar timefmt
65.Op Fl w Ar width
66.Op -
67.Op Ar file ...
68.Sh DESCRIPTION
69The
70.Nm
71utility is a printing and pagination filter for text files.
72When multiple input files are specified, each is read, formatted,
73and written to standard output.
74By default, the input is separated into 66-line pages, each with
75.Bl -bullet
76.It
77A 5-line header with the page number, date, time, and
78the pathname of the file.
79.It
80A 5-line trailer consisting of blank lines.
81.El
82.Pp
83If standard output is associated with a terminal,
84diagnostic messages are suppressed until the
85.Nm
86utility has completed processing.
87.Pp
88When multiple column output is specified,
89text columns are of equal width.
90By default text columns are separated by at least one
91.Aq Em blank .
92Input lines that do not fit into a text column are truncated.
93Lines are not truncated under single column output.
94.Sh OPTIONS
95In the following option descriptions, column, lines, offset, page, and
96width are positive decimal integers and gap is a nonnegative decimal integer.
97.Bl -tag -width 4n
98.It Ar \&+page
99Begin output at page number
100.Ar page
101of the formatted input.
102.It Fl Ar column
103Produce output that is
104.Ar columns
105wide (default is 1) that is written vertically
106down each column in the order in which the text
107is received from the input file.
108The options
109.Fl e
110and
111.Fl i
112are assumed.
113This option should not be used with
114.Fl m .
115When used with
116.Fl t ,
117the minimum number of lines is used to display the output.
118.It Fl a
119Modify the effect of the
120.Fl column
121option so that the columns are filled across the page in a round-robin order
122(e.g., when column is 2, the first input line heads column
1231, the second heads column 2, the third is the second line
124in column 1, etc.).
125This option requires the use of the
126.Fl column
127option.
128.It Fl d
129Produce output that is double spaced.
130An extra
131.Aq Em newline
132character is output following every
133.Aq newline
134found in the input.
135.It Fl e Ns Oo Ar char Oc Ns Op Ar gap
136Expand each input
137.Aq tab
138to the next greater column
139position specified by the formula
140.Ar n*gap+1 ,
141where
142.Em n
143is an integer > 0.
144If
145.Ar gap
146is zero or is omitted the default is 8.
147All
148.Aq Em tab
149characters in the input are expanded into the appropriate
150number of
151.Ao Em space Ac Ns s .
152If any nondigit character,
153.Ar char ,
154is specified, it is used as the input tab character.
155If the first character of
156.Ar char
157is a digit then
158.Ar char
159is treated as
160.Ar gap .
161.It Fl F
162Use a
163.Aq Em form-feed
164character for new pages,
165instead of the default behavior that uses a
166sequence of
167.Aq Em newline
168characters.
169.It Fl f
170Same as
171.Fl F .
172Additionally pause before beginning the first page
173if the standard output is associated with a terminal.
174.It Fl h Ar header
175Use the string
176.Ar header
177to replace the
178.Ar file name
179in the header line.
180.It Fl i Ns Oo Ar char Oc Ns Op Ar gap
181In output, replace multiple
182.Ao space Ac Ns s
183with
184.Ao tab Ac Ns s
185whenever two or more
186adjacent
187.Ao space Ac Ns s
188reach column positions
189.Ar gap+1 ,
190.Ar 2*gap+1 ,
191etc.
192If
193.Ar gap
194is zero or omitted, default
195.Aq Em tab
196settings at every eighth column position
197is used.
198If any nondigit character,
199.Ar char ,
200is specified, it is used as the output
201.Aq Em tab
202character.
203If the first character of
204.Ar char
205is a digit then
206.Ar char
207is treated as
208.Ar gap .
209.It Fl l Ar lines
210Override the 66 line default and reset the page length to
211.Ar lines .
212If
213.Ar lines
214is not greater than the sum of both the header and trailer
215depths (in lines), the
216.Nm
217utility suppresses output of both the header and trailer, as if the
218.Fl t
219option were in effect.
220.It Fl m
221Merge the contents of multiple files.
222One line from each file specified by a file operand is
223written side by side into text columns of equal fixed widths, in
224terms of the number of column positions.
225The number of text columns depends on the number of
226file operands successfully opened.
227The maximum number of files merged depends on page width and the
228per process open file limit.
229The options
230.Fl e
231and
232.Fl i
233are assumed.
234.It Fl n Ns Oo Ar char Oc Ns Op Ar width
235Provide
236.Ar width
237digit line numbering.
238The default for
239.Ar width ,
240if not specified, is 5.
241The number occupies the first
242.Ar width
243column positions of each text column or each line of
244.Fl m
245output.
246If
247.Ar char
248(any nondigit character) is given, it is appended to the line number to
249separate it from whatever follows.
250The default for
251.Ar char
252is a
253.Aq Em tab .
254Line numbers longer than
255.Ar width
256columns are truncated.
257.It Fl o Ar offset
258Each line of output is preceded by
259.Ar offset
260.Ao Em space Ac Ns s .
261If the
262.Fl o
263option is not specified, the default is zero.
264The space taken is in addition to the output line width.
265.It Fl p
266Pause before beginning each page if the
267standard output is associated with a terminal.
268.Nm
269will write an
270.Aq Em alert
271to standard error and wait for a
272.Aq Em carriage-return
273to be read on
274.Pa /dev/tty .
275.It Fl r
276Write no diagnostic reports on failure to open a file.
277.It Fl s Ns Op Ar char
278Separate text columns by the single character
279.Ar char
280instead of by the appropriate number of
281.Ao Em space Ac Ns s
282(default for
283.Ar char
284is the
285.Aq Em tab
286character).
287.It Fl T
288Specify an
289.Xr strftime 3
290format string to be used to format the date and time information in the page
291header.
292.It Fl t
293Print neither the five-line identifying
294header nor the five-line trailer usually supplied for each page.
295Quit printing after the last line of each file without spacing to the
296end of the page.
297.It Fl w Ar width
298Set the width of the line to
299.Ar width
300column positions for multiple text-column output only.
301If the
302.Fl w
303option is not specified and the
304.Fl s
305option is not specified, the default width is 72.
306If the
307.Fl w
308option is not specified and the
309.Fl s
310option is specified, the default width is 512.
311.It Ar file
312A pathname of a file to be printed.
313If no
314.Ar file
315operands are specified, or if a
316.Ar file
317operand is
318.Sq Fl ,
319the standard input is used.
320The standard input is used only if no
321.Ar file
322operands are specified, or if a
323.Ar file
324operand is
325.Sq Fl .
326.El
327.Pp
328The
329.Fl s
330option does not allow the option letter to be separated from its
331argument, and the options
332.Fl e ,
333.Fl i ,
334and
335.Fl n
336require that both arguments, if present, not be separated from the option
337letter.
338.Sh ERRORS
339If
340.Nm
341receives an interrupt while printing to a terminal, it
342flushes all accumulated error messages to the screen before
343terminating.
344.Pp
345The
346.Nm
347utility exits 0 on success, and 1 if an error occurs.
348.Pp
349Error messages are written to standard error during the printing
350process (if output is redirected) or after all successful
351file printing is complete (when printing to a terminal).
352.Sh SEE ALSO
353.Xr cat 1 ,
354.Xr more 1 ,
355.Xr strftime 3
356.Sh STANDARDS
357The
358.Nm
359utility is
360.St -p1003.1-2008
361compatible.
362.Sh HISTORY
363A
364.Nm
365utility appeared in
366.At v1 .
367