PR(1)                      POSIX Programmer's Manual                     PR(1)



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


NNAAMMEE
       pr -- print files

SSYYNNOOPPSSIISS
       pr [[+_p_a_g_e]] [[-_c_o_l_u_m_n]] [[-adFmrt]] [[-e[[_c_h_a_r]][[_g_a_p]]]] [[-h _h_e_a_d_e_r]] [[-i[[_c_h_a_r]][[_g_a_p]]]]
           [[-l _l_i_n_e_s]] [[-n[[_c_h_a_r]][[_w_i_d_t_h]]]] [[-o _o_f_f_s_e_t]] [[-s[[_c_h_a_r]]]] [[-w _w_i_d_t_h]] [[-fp]]
           [[_f_i_l_e...]]

DDEESSCCRRIIPPTTIIOONN
       The _p_r utility is a printing and pagination filter. If multiple input
       files are specified, each shall be read, formatted, and written to
       standard output. By default, the input shall be separated into 66-line
       pages, each with:

        *  A 5-line header that includes the page number, date, time, and the
           pathname of the file

        *  A 5-line trailer consisting of blank lines

       If standard output is associated with a terminal, diagnostic messages
       shall be deferred until the _p_r utility has completed processing.

       When options specifying multi-column output are specified, output text
       columns shall be of equal width; input lines that do not fit into a
       text column shall be truncated. By default, text columns shall be
       separated with at least one <blank>.

OOPPTTIIOONNSS
       The _p_r utility shall conform to the Base Definitions volume of
       POSIX.1-2008, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s, except that: the
       _p_a_g_e option has a ''++'' delimiter; _p_a_g_e and _c_o_l_u_m_n can be multi-digit
       numbers; some of the option-arguments are optional; and some of the
       option-arguments cannot be specified as separate arguments from the
       preceding option letter. In particular, the --ss option does not allow
       the option letter to be separated from its argument, and the options
       --ee, --ii, and --nn require that both arguments, if present, not be
       separated from the option letter.

       The following options shall be supported. In the following option
       descriptions, _c_o_l_u_m_n, _l_i_n_e_s, _o_f_f_s_e_t, _p_a_g_e, and _w_i_d_t_h are positive
       decimal integers; _g_a_p is a non-negative decimal integer.

       ++_p_a_g_e     Begin output at page number _p_a_g_e of the formatted input.

       --_c_o_l_u_m_n   Produce multi-column output that is arranged in _c_o_l_u_m_n
                 columns (the default shall be 1) and is written down each
                 column in the order in which the text is received from the
                 input file. This option should not be used with --mm.  The
                 options --ee and --ii shall be assumed for multiple text-column
                 output. Whether or not text columns are produced with
                 identical vertical lengths is unspecified, but a text column
                 shall never exceed the length of the page (see the --ll
                 option). When used with --tt, use the minimum number of lines
                 to write the output.

       --aa        Modify the effect of the --_c_o_l_u_m_n option so that the columns
                 are filled across the page in a round-robin order (for
                 example, when _c_o_l_u_m_n is 2, the first input line heads column
                 1, the second heads column 2, the third is the second line in
                 column 1, and so on).

       --dd        Produce output that is double-spaced; append an extra
                 <newline> following every <newline> found in the input.

       --ee[[_c_h_a_r]][[_g_a_p]]
                 Expand each input <tab> to the next greater column position
                 specified by the formula _n*_g_a_p+1, where _n is an integer > 0.
                 If _g_a_p is zero or is omitted, it shall default to 8. All
                 <tab> characters in the input shall be expanded into the
                 appropriate number of <space> characters. If any non-digit
                 character, _c_h_a_r, is specified, it shall be used as the input
                 <tab>.  If the first character of the --ee option-argument is a
                 digit, the entire option-argument shall be assumed to be _g_a_p.

       --ff        Use a <form-feed> for new pages, instead of the default
                 behavior that uses a sequence of <newline> characters. Pause
                 before beginning the first page if the standard output is
                 associated with a terminal.

       --FF        Use a <form-feed> for new pages, instead of the default
                 behavior that uses a sequence of <newline> characters.

       --hh _h_e_a_d_e_r Use the string _h_e_a_d_e_r to replace the contents of the _f_i_l_e
                 operand in the page header.

       --ii[[_c_h_a_r]][[_g_a_p]]
                 In output, replace <space> characters with <tab> characters
                 wherever one or more adjacent <space> characters reach column
                 positions _g_a_p+1, 2* _g_a_p+1, 3* _g_a_p+1, and so on. If _g_a_p is
                 zero or is omitted, default tab settings at every eighth
                 column position shall be assumed. If any non-digit character,
                 _c_h_a_r, is specified, it shall be used as the output <tab>.  If
                 the first character of the --ii option-argument is a digit, the
                 entire option-argument shall be assumed to be _g_a_p.

       --ll _l_i_n_e_s  Override the 66-line default and reset the page length to
                 _l_i_n_e_s.  If _l_i_n_e_s is not greater than the sum of both the
                 header and trailer depths (in lines), the _p_r utility shall
                 suppress both the header and trailer, as if the --tt option
                 were in effect.

       --mm        Merge files. Standard output shall be formatted so the _p_r
                 utility writes one line from each file specified by a _f_i_l_e
                 operand, side by side into text columns of equal fixed
                 widths, in terms of the number of column positions.
                 Implementations shall support merging of at least nine _f_i_l_e
                 operands.

       --nn[[_c_h_a_r]][[_w_i_d_t_h]]
                 Provide _w_i_d_t_h-digit line numbering (default for _w_i_d_t_h shall
                 be 5). The number shall occupy the first _w_i_d_t_h column
                 positions of each text column of default output or each line
                 of --mm output. If _c_h_a_r (any non-digit character) is given, it
                 shall be appended to the line number to separate it from
                 whatever follows (default for _c_h_a_r is a <tab>).

       --oo _o_f_f_s_e_t Each line of output shall be preceded by offset <space>
                 characters. If the --oo option is not specified, the default
                 offset shall be zero. The space taken is in addition to the
                 output line width (see the --ww option below).

       --pp        Pause before beginning each page if the standard output is
                 directed to a terminal (_p_r shall write an <alert> to standard
                 error and wait for a <carriage-return> to be read on
                 //ddeevv//ttttyy).

       --rr        Write no diagnostic reports on failure to open files.

       --ss[[_c_h_a_r]]  Separate text columns by the single character _c_h_a_r instead of
                 by the appropriate number of <space> characters (default for
                 _c_h_a_r shall be <tab>).

       --tt        Write neither the five-line identifying header nor the five-
                 line trailer usually supplied for each page. Quit writing
                 after the last line of each file without spacing to the end
                 of the page.

       --ww _w_i_d_t_h  Set the width of the line to _w_i_d_t_h column positions for
                 multiple text-column output only. If the --ww option is not
                 specified and the --ss option is not specified, the default
                 width shall be 72. If the --ww option is not specified and the
                 --ss option is specified, the default width shall be 512.

                 For single column output, input lines shall not be truncated.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      A pathname of a file to be written. If no _f_i_l_e operands are
                 specified, or if a _f_i_l_e operand is ''--'', the standard input
                 shall be used.

SSTTDDIINN
       The standard input shall be used only if no _f_i_l_e operands are
       specified, or if a _f_i_l_e operand is ''--''.  See the INPUT FILES section.

IINNPPUUTT FFIILLEESS
       The input files shall be text files.

       The file //ddeevv//ttttyy shall be used to read responses required by the --pp
       option.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _p_r:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2008, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s the precedence of internationalization variables
                 used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_T_Y_P_E  Determine the locale for the interpretation of sequences of
                 bytes of text data as characters (for example, single-byte as
                 opposed to multi-byte characters in arguments and input
                 files) and which characters are defined as printable
                 (character class pprriinntt).  Non-printable characters are still
                 written to standard output, but are not counted for the
                 purpose for column-width and line-length calculations.

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic messages written to standard
                 error.

       _L_C___T_I_M_E   Determine the format of the date and time for use in writing
                 header lines.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

       _T_Z        Determine the timezone used to calculate date and time
                 strings written in header lines. If _T_Z is unset or null, an
                 unspecified default timezone shall be used.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       If _p_r receives an interrupt while writing to a terminal, it shall flush
       all accumulated error messages to the screen before terminating.

SSTTDDOOUUTT
       The _p_r utility output shall be a paginated version of the original file
       (or files). This pagination shall be accomplished using either <form-
       feed> characters or a sequence of <newline> characters, as controlled
       by the --FF or --ff option. Page headers shall be generated unless the --tt
       option is specified. The page headers shall be of the form:

           ""\\nn\\nn%%ss %%ss PPaaggee %%dd\\nn\\nn\\nn"",, <<_o_u_t_p_u_t _o_f _d_a_t_e>>,, <<_f_i_l_e>, <_p_a_g_e _n_u_m_b_e_r>

       In the POSIX locale, the <_o_u_t_p_u_t _o_f _d_a_t_e> field, representing the date
       and time of last modification of the input file (or the current date
       and time if the input file is standard input), shall be equivalent to
       the output of the following command as it would appear if executed at
       the given time:

           ddaattee ""++%%bb %%ee %%HH::%%MM %%YY""

       without the trailing <newline>, if the page being written is from
       standard input. If the page being written is not from standard input,
       in the POSIX locale, the same format shall be used, but the time used
       shall be the modification time of the file corresponding to _f_i_l_e
       instead of the current time. When the _L_C___T_I_M_E locale category is not
       set to the POSIX locale, a different format and order of presentation
       of this field may be used.

       If the standard input is used instead of a _f_i_l_e operand, the <_f_i_l_e>
       field shall be replaced by a null string.

       If the --hh option is specified, the <_f_i_l_e> field shall be replaced by
       the _h_e_a_d_e_r argument.

SSTTDDEERRRR
       The standard error shall be used for diagnostic messages and for
       alerting the terminal when --pp is specified.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Successful completion.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       A conforming application must protect its first operand, if it starts
       with a <plus-sign>, by preceding it with the ""----"" argument that denotes
       the end of the options. For example, _p_r+_x could be interpreted as an
       invalid page number or a _f_i_l_e operand.

EEXXAAMMPPLLEESS
        1. Print a numbered list of all files in the current directory:

               llss --aa || pprr --nn --hh ""FFiilleess iinn $$((ppwwdd))..""

        2. Print ffiillee11 and ffiillee22 as a double-spaced, three-column listing
           headed by ``file list'':

               pprr --33dd --hh ""ffiillee lliisstt"" ffiillee11 ffiillee22

        3. Write ffiillee11 on ffiillee22, expanding tabs to columns 10, 19, 28, ...:

               pprr --ee99 --tt <<ffiillee11 >>ffiillee22

RRAATTIIOONNAALLEE
       This utility is one of those that does not follow the Utility Syntax
       Guidelines because of its historical origins. The standard developers
       could have added new options that obeyed the guidelines (and marked the
       old options obsolescent) or devised an entirely new utility; there are
       examples of both actions in this volume of POSIX.1-2008. Because of its
       widespread use by historical applications, the standard developers
       decided to exempt this version of _p_r from many of the guidelines.

       Implementations are required to accept option-arguments to the --hh, --ll,
       --oo, and --ww options whether presented as part of the same argument or as
       a separate argument to _p_r, as suggested by the Utility Syntax
       Guidelines. The --nn and --ss options, however, are specified as in
       historical practice because they are frequently specified without their
       optional arguments. If a <blank> were allowed before the option-
       argument in these cases, a _f_i_l_e operand could mistakenly be interpreted
       as an option-argument in historical applications.

       The text about the minimum number of lines in multi-column output was
       included to ensure that a best effort is made in balancing the length
       of the columns. There are known historical implementations in which,
       for example, 60-line files are listed by _p_r -2 as one column of 56
       lines and a second of 4. Although this is not a problem when a full
       page with headers and trailers is produced, it would be relatively
       useless when used with --tt.

       Historical implementations of the _p_r utility have differed in the
       action taken for the --ff option. BSD uses it as described here for the
       --FF option; System V uses it to change trailing <newline> characters on
       each page to a <form-feed> and, if standard output is a TTY device,
       sends an <alert> to standard error and reads a line from //ddeevv//ttttyy
       before the first page. There were strong arguments from both sides of
       this issue concerning historical practice and as a result the --FF option
       was added. XSI-conformant systems support the System V historical
       actions for the --ff option.

       The <_o_u_t_p_u_t _o_f _d_a_t_e> field in the --ll format is specified only for the
       POSIX locale. As noted, the format can be different in other locales.
       No mechanism for defining this is present in this volume of
       POSIX.1-2008, as the appropriate vehicle is a message catalog; that is,
       the format should be specified as a ``message''.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _e_x_p_a_n_d, _l_p

       The Base Definitions volume of POSIX.1-2008, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                                PR(1)
