PR(1P)
π PROLOG π
okay so bestie, welcome to PR(1P) β yes, the whole manual page, and before we even get into the printing-and-pagination situation: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so go consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux at all. not a drill, fr fr. π
β¨ NAME β¨
pr β print files. that's the whole name. iconic. π
π¦ SYNOPSIS π¦
the vibe check, syntax edition:
pr [+page] [-column] [-adFmrt] [-e[char][gap]] [-h header] [-i[char][gap]]
[-l lines] [-n[char][width]] [-o offset] [-s[char]] [-w width] [-fp]
[file...]
π DESCRIPTION π
The pr 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 pr 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>.
π OPTIONS π
okay so the pr utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines, except that: the page option has a + delimiter; page and column 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 -s option does not allow the option letter to be separated from its argument, and the options -e, -i, and -n require that both arguments, if present, not be separated from the option letter.
The following options shall be supported. In the following option descriptions, column, lines, offset, page, and width are positive decimal integers; gap is a non-negative decimal integer.
+pageβ Begin output at page number page of the formatted input.-columnβ Produce multi-column output that is arranged in column columns (the default shall be1) 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-m. The options-eand-ishall 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-loption). When used with-t, use the minimum number of lines to write the output.-aβ Modify the effect of the-columnoption so that the columns are filled across the page in a round-robin order (for example, when column is2, the first input line heads column 1, the second heads column 2, the third is the second line in column 1, and so on).-dβ Produce output that is double-spaced; append an extra<newline>following every<newline>found in the input.-e[char][gap]β Expand each input<tab>to the next greater column position specified by the formulan*gap+1, where n is an integer> 0. If gap is zero or is omitted, it shall default to8. All<tab>characters in the input shall be expanded into the appropriate number of<space>characters. If any non-digit character, char, is specified, it shall be used as the input<tab>. If the first character of the-eoption-argument is a digit, the entire option-argument shall be assumed to be gap.-fβ 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.-Fβ Use a<form-feed>for new pages, instead of the default behavior that uses a sequence of<newline>characters.-h headerβ Use the string header to replace the contents of the file operand in the page header.-i[char][gap]β In output, replace<space>characters with<tab>characters wherever one or more adjacent<space>characters reach column positionsgap+1,2* gap+1,3* gap+1, and so on. If gap is zero or is omitted, default tab settings at every eighth column position shall be assumed. If any non-digit character, char, is specified, it shall be used as the output<tab>. If the first character of the-ioption-argument is a digit, the entire option-argument shall be assumed to be gap.-l linesβ Override the66-linedefault and reset the page length to lines. If lines is not greater than the sum of both the header and trailer depths (in lines), theprutility shall suppress both the header and trailer, as if the-toption were in effect.-mβ Merge files. Standard output shall be formatted so theprutility writes one line from each file specified by a file 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 file operands.-n[char][width]β Provide width-digit line numbering (default for width shall be5). The number shall occupy the first width column positions of each text column of default output or each line of-moutput. If char (any non-digit character) is given, it shall be appended to the line number to separate it from whatever follows (default for char is a<tab>).-o offsetβ Each line of output shall be preceded by offset<space>characters. If the-ooption is not specified, the default offset shall be zero. The space taken is in addition to the output line width (see the-woption below).-pβ Pause before beginning each page if the standard output is directed to a terminal (prshall write an<alert>to standard error and wait for a<carriage-return>to be read on/dev/tty).-rβ Write no diagnostic reports on failure to open files.-s[char]β Separate text columns by the single character char instead of by the appropriate number of<space>characters (default for char shall be<tab>).-tβ 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.-w widthβ Set the width of the line to width column positions for multiple text-column output only. If the-woption is not specified and the-soption is not specified, the default width shall be72. If the-woption is not specified and the-soption is specified, the default width shall be512.
For single column output, input lines shall not be truncated.
π OPERANDS π
The following operand shall be supported:
fileβ A pathname of a file to be written. If nofileoperands are specified, or if afileoperand is'-', the standard input shall be used.
π§ STDIN π§
The standard input shall be used only if no file operands are specified, or if a file operand is '-'. See the INPUT FILES section.
πΈ INPUT FILES πΈ
The input files shall be text files.
The file /dev/tty shall be used to read responses required by the -p option.
π ENVIRONMENT VARIABLES π
The following environment variables shall affect the execution of pr:
LANGβ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ If set to a non-empty string value, override the values of all the other internationalization variables.LC_CTYPEβ 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 classprint). Non-printable characters are still written to standard output, but are not counted for the purpose for column-width and line-length calculations.LC_MESSAGESβ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.LC_TIMEβ Determine the format of the date and time for use in writing header lines.NLSPATHβ Determine the location of message catalogs for the processing ofLC_MESSAGES.TZβ Determine the timezone used to calculate date and time strings written in header lines. IfTZis unset or null, an unspecified default timezone shall be used.
β‘ ASYNCHRONOUS EVENTS β‘
If pr receives an interrupt while writing to a terminal, it shall flush all accumulated error messages to the screen before terminating.
β¨ STDOUT β¨
okay so bestie, what pr spits out is a paginated version of the original file (or files, plural, we contain multitudes π
). This pagination gets done using either <form-feed> characters or a whole lil sequence of <newline> characters β whichever one you want, controlled by the -F or -f option. π
Page headers get generated unless you specified -t. And the page headers look like this, exactly:
"\n\n%s %s Page %d\n\n\n", <output of date>, <file>, <page number>
In the POSIX locale, the <output of date> field β which represents 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 this command as it would appear if it was executed at the given time:
date "+%b %e %H:%M %Y"
...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 file instead of the current time. And when the LC_TIME locale category is not set to the POSIX locale? A different format and order of presentation of this field may be used. iykyk π
If the standard input is used instead of a file operand, the <file> field shall be replaced by a null string. (Empty. Blank. Gone. π)
And if the -h option is specified, the <file> field shall be replaced by the header argument. π«Ά
π STDERR
The standard error shall be used for diagnostic messages and for alerting the terminal when -p is specified. so like, when it needs to yell at u, that's where the yelling goes β¨
π OUTPUT FILES
None.
that's it that's the section. nothing. nada. zero files. π
π EXTENDED DESCRIPTION
None.
(also empty, we love a low-effort section π)
π₯ EXIT STATUS
The following exit values shall be returned:
0β Successful completion. slay. π>0β An error occurred. not slay. π
πΈ CONSEQUENCES OF ERRORS
Default.
The following sections are informative. (heads up bestie, we're in the bonus content zone now π)
π APPLICATION USAGE
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, pr+x could be interpreted as an invalid page number or a file operand. so protect ur weird little + filenames, they're fragile π₯Ί
β¨ EXAMPLES β¨
- Print a numbered list of all files in the current directory:
ls -a | pr -n -h "Files in $(pwd)."
- Print
file1andfile2as a double-spaced, three-column listing headed byfile list:
pr -3d -h "file list" file1 file2
- Write
file1onfile2, expanding tabs to columns 10, 19, 28, ...:
pr -e9 -t <file1 >file2
π§ RATIONALE
okay so storytime bestie, grab a snack π
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β2017. But because of its widespread use by historical applications, the standard developers decided to exempt this version of pr from many of the guidelines. iconic, honestly. π
Implementations are required to accept option-arguments to the -h, -l, -o, and -w options whether presented as part of the same argument or as a separate argument to pr, as suggested by the Utility Syntax Guidelines. The -n and -s 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 file operand could mistakenly be interpreted as an option-argument in historical applications. so like, that's the lore behind why it's Like That π
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 pr -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 -t. (56 and 4. not balanced. not the vibe. π)
Historical implementations of the pr utility have differed in the action taken for the -f option. BSD uses it as described here for the -F 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 /dev/tty before the first page. There were strong arguments from both sides of this issue concerning historical practice and as a result the -F option was added. XSI-conformant systems support the System V historical actions for the -f option. messy history, we still love her π«Ά
The <output of date> field in the -l 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β2017, as the appropriate vehicle is a message catalog; that is, the format should be specified as a message.
π FUTURE DIRECTIONS
None.
π¦ SEE ALSO
expand,lp- The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
π COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/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 .
and that's the whole page bestie, we did it π this beauty is from IEEE/The Open Group, dated 2017, and it lives under the name PR(1P) π thanks for reading the whole thing with me, ur literally the main character of man pages now β
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms