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

NAME

6       pr - print files
7

SYNOPSIS

9       pr [+page][-column][-adFmrt][-e[char][ gap]][-h header][-i[char][gap]]
10
11               [-l lines][-n[char][width]][-o offset][-s[char]][-w width][-fp]
12               [file...]
13

DESCRIPTION

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

OPTIONS

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

OPERANDS

151       The following operand shall be supported:
152
153       file   A  pathname  of  a  file  to be written. If no file operands are
154              specified, or if a file operand is  '-'  ,  the  standard  input
155              shall be used.
156
157

STDIN

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

INPUT FILES

163       The input files shall be text files.
164
165       The file /dev/tty shall be used to read responses required  by  the  -p
166       option.
167

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

207       If pr receives an interrupt while writing to a terminal, it shall flush
208       all accumulated error messages to the screen before terminating.
209

STDOUT

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

STDERR

244       The standard error shall be used for diagnostic messages and for alert‐
245       ing the terminal when -p is specified.
246

OUTPUT FILES

248       None.
249

EXTENDED DESCRIPTION

251       None.
252

EXIT STATUS

254       The following exit values shall be returned:
255
256        0     Successful completion.
257
258       >0     An error occurred.
259
260

CONSEQUENCES OF ERRORS

262       Default.
263
264       The following sections are informative.
265

APPLICATION USAGE

267       None.
268

EXAMPLES

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

RATIONALE

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

FUTURE DIRECTIONS

330       None.
331

SEE ALSO

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