1PR(1P)                     POSIX Programmer's Manual                    PR(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       pr - print files
13

SYNOPSIS

15       pr [+page][-column][-adFmrt][-e[char][ gap]][-h header][-i[char][gap]]
16
17               [-l lines][-n[char][width]][-o offset][-s[char]][-w width][-fp]
18               [file...]
19

DESCRIPTION

21       The pr utility is a printing and pagination filter. If  multiple  input
22       files  are  specified,  each  shall  be read, formatted, and written to
23       standard output. By default, the input shall be separated into  66-line
24       pages, each with:
25
26        * A  5-line  header that includes the page number, date, time, and the
27          pathname of the file
28
29        * A 5-line trailer consisting of blank lines
30
31       If standard output is associated with a terminal,  diagnostic  messages
32       shall be deferred until the pr utility has completed processing.
33
34       When  options specifying multi-column output are specified, output text
35       columns shall be of equal width; input lines that do  not  fit  into  a
36       text column shall be truncated. By default, text columns shall be sepa‐
37       rated with at least one <blank>.
38

OPTIONS

40       The pr  utility  shall  conform  to  the  Base  Definitions  volume  of
41       IEEE Std 1003.1-2001,  Section  12.2, Utility Syntax Guidelines, except
42       that: the page option has a '+'  delimiter;  page  and  column  can  be
43       multi-digit  numbers;  some  of  the option-arguments are optional; and
44       some of the option-arguments cannot be specified as separate  arguments
45       from the preceding option letter. In particular, the -s option does not
46       allow the option letter to be separated  from  its  argument,  and  the
47       options  -e, -i, and -n require that both arguments, if present, not be
48       separated from the option letter.
49
50       The following options shall  be  supported.  In  the  following  option
51       descriptions, column, lines, offset, page, and width are positive deci‐
52       mal integers; gap is a non-negative decimal integer.
53
54       +page  Begin output at page number page of the formatted input.
55
56       -column
57              Produce multi-column output that is arranged in  column  columns
58              (the  default shall be 1) and is written down each column in the
59              order in which the text is received from the  input  file.  This
60              option  should  not be used with -m. The options -e and -i shall
61              be assumed for multiple text-column output.  Whether or not text
62              columns are produced with identical vertical lengths is unspeci‐
63              fied, but a text column shall never exceed  the  length  of  the
64              page  (see  the  -l  option). When used with -t, use the minimum
65              number of lines to write the output.
66
67       -a     Modify the effect of the - column option so that the columns are
68              filled across the page in a round-robin order (for example, when
69              column is 2, the first input line heads  column  1,  the  second
70              heads column 2, the third is the second line in column 1, and so
71              on).
72
73       -d     Produce output that is double-spaced; append an extra  <newline>
74              following every <newline> found in the input.
75
76       -e[char][gap]
77
78              Expand  each  input  <tab>  to  the next greater column position
79              specified by the formula n* gap+1, where n is an integer > 0. If
80              gap  is zero or is omitted, it shall default to 8. All <tab>s in
81              the input shall be  expanded  into  the  appropriate  number  of
82              <space>s.  If  any  non-digit  character, char, is specified, it
83              shall be used as the input <tab>.
84
85       -f     Use a <form-feed> for new pages, instead of the default behavior
86              that  uses  a sequence of <newline>s. Pause before beginning the
87              first page if the standard output is associated with a terminal.
88
89       -F     Use a <form-feed> for new pages, instead of the default behavior
90              that uses a sequence of <newline>s.
91
92       -h  header
93              Use  the string header to replace the contents of the file oper‐
94              and in the page header.
95
96       -i[char][gap]
97              In output, replace multiple <space>s with <tab>s wherever two or
98              more  adjacent  <space>s reach column positions gap+1, 2* gap+1,
99              3* gap+1, and so on.  If gap is zero or is omitted, default  tab
100              settings  at  every  eighth column position shall be assumed. If
101              any non-digit character, char, is specified, it shall be used as
102              the output <tab>.
103
104       -l  lines
105              Override the 66-line default and reset the page length to lines.
106              If lines is not greater than the sum  of  both  the  header  and
107              trailer  depths  (in  lines), the pr utility shall suppress both
108              the header and trailer, as if the -t option were in effect.
109
110       -m     Merge files. Standard output shall be formatted so the pr  util‐
111              ity  writes one line from each file specified by a file operand,
112              side by side into text columns of equal fixed widths,  in  terms
113              of  the  number of column positions.  Implementations shall sup‐
114              port merging of at least nine file operands.
115
116       -n[char][width]
117
118              Provide width-digit line numbering (default for width  shall  be
119              5).  The number shall occupy the first width column positions of
120              each text column of default output or each line of -m output. If
121              char (any non-digit character) is given, it shall be appended to
122              the line number to separate it from  whatever  follows  (default
123              for char is a <tab>).
124
125       -o  offset
126              Each line of output shall be preceded by offset <space>s. If the
127              -o option is not specified, the default offset  shall  be  zero.
128              The space taken is in addition to the output line width (see the
129              -w option below).
130
131       -p     Pause before beginning each  page  if  the  standard  output  is
132              directed  to  a terminal ( pr shall write an <alert> to standard
133              error and wait for a <carriage-return> to be read on /dev/tty).
134
135       -r     Write no diagnostic reports on failure to open files.
136
137       -s[char]
138              Separate text columns by the single character char instead of by
139              the  appropriate  number  of <space>s (default for char shall be
140              <tab>).
141
142       -t     Write neither the five-line identifying header nor the five-line
143              trailer  usually  supplied for each page. Quit writing after the
144              last line of each file without spacing to the end of the page.
145
146       -w  width
147              Set the width of the line to width column positions for multiple
148              text-column  output  only. If the -w option is not specified and
149              the -s option is not specified, the default width shall  be  72.
150              If  the  -w  option is not specified and the -s option is speci‐
151              fied, the default width shall be 512.
152
153       For single column output, input lines shall not be truncated.
154
155

OPERANDS

157       The following operand shall be supported:
158
159       file   A pathname of a file to be written.  If  no  file  operands  are
160              specified, or if a file operand is '-', the standard input shall
161              be used.
162
163

STDIN

165       The standard input shall be used only if no file  operands  are  speci‐
166       fied, or if a file operand is '-' .  See the INPUT FILES section.
167

INPUT FILES

169       The input files shall be text files.
170
171       The  file  /dev/tty  shall be used to read responses required by the -p
172       option.
173

ENVIRONMENT VARIABLES

175       The following environment variables shall affect the execution of pr:
176
177       LANG   Provide a default value for the  internationalization  variables
178              that  are  unset  or  null.  (See the Base Definitions volume of
179              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
180              ables  for the precedence of internationalization variables used
181              to determine the values of locale categories.)
182
183       LC_ALL If set to a non-empty string value, override the values  of  all
184              the other internationalization variables.
185
186       LC_CTYPE
187              Determine  the  locale  for  the  interpretation of sequences of
188              bytes of text data as characters (for  example,  single-byte  as
189              opposed  to  multi-byte characters in arguments and input files)
190              and which characters are defined as printable  (character  class
191              print).  Non-printable  characters are still written to standard
192              output, but are not counted for the purpose for column-width and
193              line-length calculations.
194
195       LC_MESSAGES
196              Determine  the  locale  that should be used to affect the format
197              and contents of diagnostic messages written to standard error.
198
199       LC_TIME
200              Determine the format of the date and time  for  use  in  writing
201              header lines.
202
203       NLSPATH
204              Determine the location of message catalogs for the processing of
205              LC_MESSAGES .
206
207       TZ     Determine the timezone used to calculate date and  time  strings
208              written  in header lines. If TZ is unset or null, an unspecified
209              default timezone shall be used.
210
211

ASYNCHRONOUS EVENTS

213       If pr receives an interrupt while writing to a terminal, it shall flush
214       all accumulated error messages to the screen before terminating.
215

STDOUT

217       The pr utility output shall be a paginated version of the original file
218       (or files). This pagination shall be accomplished using  either  <form-
219       feed>s  or  a  sequence  of  <newline>s, as controlled by the -F  or -f
220       option. Page headers shall be generated unless the -t option is  speci‐
221       fied. The page headers shall be of the form:
222
223
224              "\n\n%s %s Page %d\n\n\n", <output of date>, <file>, <page number>
225
226       In  the POSIX locale, the <output of date> field, representing the date
227       and time of last modification of the input file (or  the  current  date
228       and  time  if the input file is standard input), shall be equivalent to
229       the output of the following command as it would appear if  executed  at
230       the given time:
231
232
233              date "+%b %e %H:%M %Y"
234
235       without the trailing <newline>, if the page being written is from stan‐
236       dard input. If the page being written is not from  standard  input,  in
237       the  POSIX  locale,  the  same  format shall be used, but the time used
238       shall be the modification  time  of  the  file  corresponding  to  file
239       instead  of  the  current time. When the LC_TIME locale category is not
240       set to the POSIX locale, a different format and order  of  presentation
241       of this field may be used.
242
243       If  the  standard  input  is used instead of a file operand, the <file>
244       field shall be replaced by a null string.
245
246       If the -h option is specified, the <file> field shall  be  replaced  by
247       the header argument.
248

STDERR

250       The standard error shall be used for diagnostic messages and for alert‐
251       ing the terminal when -p is specified.
252

OUTPUT FILES

254       None.
255

EXTENDED DESCRIPTION

257       None.
258

EXIT STATUS

260       The following exit values shall be returned:
261
262        0     Successful completion.
263
264       >0     An error occurred.
265
266

CONSEQUENCES OF ERRORS

268       Default.
269
270       The following sections are informative.
271

APPLICATION USAGE

273       None.
274

EXAMPLES

276        1. Print a numbered list of all files in the current directory:
277
278
279           ls -a | pr -n -h "Files in $(pwd)."
280
281        2. Print file1 and file2  as  a  double-spaced,  three-column  listing
282           headed by "file list'':
283
284
285           pr -3d -h "file list" file1 file2
286
287        3. Write file1 on file2, expanding tabs to columns 10, 19, 28, ...:
288
289
290           pr -e9 -t <file1 >file2
291

RATIONALE

293       This  utility  is  one of those that does not follow the Utility Syntax
294       Guidelines because of its historical origins. The  standard  developers
295       could have added new options that obeyed the guidelines (and marked the
296       old options obsolescent) or devised an entirely new utility; there  are
297       examples  of  both  actions  in  this  volume  of IEEE Std 1003.1-2001.
298       Because of its widespread use by historical applications, the  standard
299       developers decided to exempt this version of pr from many of the guide‐
300       lines.
301
302       Implementations are required to accept option-arguments to the -h,  -l,
303       -o, and -w options whether presented as part of the same argument or as
304       a separate argument to pr, as suggested by the  Utility  Syntax  Guide‐
305       lines.  The  -n and -s options, however, are specified as in historical
306       practice because they are frequently specified without  their  optional
307       arguments.  If  a  <blank>  were  allowed before the option-argument in
308       these cases, a file operand  could  mistakenly  be  interpreted  as  an
309       option-argument in historical applications.
310
311       The  text  about the minimum number of lines in multi-column output was
312       included to ensure that a best effort is made in balancing  the  length
313       of  the  columns.  There are known historical implementations in which,
314       for example, 60-line files are listed by pr -2  as  one  column  of  56
315       lines  and  a  second  of 4. Although this is not a problem when a full
316       page with headers and trailers is produced, it would be relatively use‐
317       less when used with -t.
318
319       Historical  implementations  of  the  pr  utility  have differed in the
320       action taken for the -f option. BSD uses it as described here  for  the
321       -F  option; System V uses it to change trailing <newline>s on each page
322       to a <form-feed> and, if standard output is  a  TTY  device,  sends  an
323       <alert>  to  standard  error  and reads a line from /dev/tty before the
324       first page. There were strong arguments from both sides of  this  issue
325       concerning historical practice and as a result the -F option was added.
326       XSI-conformant systems support the System V historical actions for  the
327       -f option.
328
329       The  <output of date>  field in the -l format is specified only for the
330       POSIX locale. As noted, the format can be different in  other  locales.
331       No   mechanism   for  defining  this  is  present  in  this  volume  of
332       IEEE Std 1003.1-2001, as the appropriate vehicle is a message  catalog;
333       that is, the format should be specified as a "message".
334

FUTURE DIRECTIONS

336       None.
337

SEE ALSO

339       expand, lp
340
342       Portions  of  this text are reprinted and reproduced in electronic form
343       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
344       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
345       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
346       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
347       event of any discrepancy between this version and the original IEEE and
348       The  Open Group Standard, the original IEEE and The Open Group Standard
349       is the referee document. The original Standard can be  obtained  online
350       at http://www.opengroup.org/unix/online.html .
351
352
353
354IEEE/The Open Group                  2003                               PR(1P)
Impressum