Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

pr

Break a file into pages and/or columns for printing

Syntax:

pr [+page] [-column] [-adFmrt] [-e[char][gap]] 
[-L locale] [-h header] 
[-i[char][gap]] [-l lines] 
[-o offset] [-s[char]] [-n[char][width]] 
[-w width] [file …] 

Runs on:

Neutrino

Options:

In the following option descriptions, column, lines, offset, page, and width are positive decimal integers, and gap is a nonnegative decimal integer.


Note: Options -e, -i, -n, and -s, do not use spaces to separate options and arguments.

+page
Print the pages starting with this page number.
-column
Produce output that is columns wide (the default is 1). The text is written vertically down each column in the order in which it is received from the input file. The options -e and -i are assumed. Don't use this option with -m. If you want to display the output using the minimum number of lines, use with -t.
-a
Modify the effect of the -column option so that the columns are filled across the page in a round-robin order (e.g. when column is 2, the first input line heads column 1, the second heads column 2, the third is the second line in column 1, etc.). If you use this option, you must also use the -column option.
-d
Double space the output. An extra newline character is output following every newline found in the input.
-e[char][gap]
Expand each input tab to the next greater column position specified by the formula n*gap+1, where n is an integer > 0. If gap is zero or is omitted, the default is 8. All tab characters in the input are expanded into the appropriate number of spaces. If char (any nondigit character) is specified, it is used as the input tab character.
-F
Use a form-feed character for new pages, instead of the default behavior that uses a sequence of newline characters.
-h header
Use the string header to replace the file name in the header line.
-i[char][gap]
In the output, replace multiple spaces with tabs whenever two or more adjacent spaces reach column positions gap+1, 2*gap+1, etc. If gap is zero or omitted, the default tab settings are at every eighth column position. If char (any nondigit character) is specified, it is used as the output tab character.
-L locale
Use the locale specified as argument instead of one found in the environment. Use C to reset locale to its default.
-l lines
(“el”) Override the 66-line default and reset the page length to lines. If lines is not greater than the sum of both the header and trailer depths (in lines), the pr utility suppresses output of both the header and trailer, as if the -t option were in effect.
-m
Merge the contents of multiple files. One line from each file specified by a file operand is written side by side into text columns of equal fixed widths, in terms of the number of column positions. The number of text columns depends on the number of file operands successfully opened. The maximum number of files merged depends on page width and the per-process open file limit. The options -e and -i are assumed.
-n[char][width]
Provide width-digit line numbering. The default for width, if not specified, is 5. The number occupies the first width column positions of each text column or each line of -m output. If char (any nondigit character) is given, it is appended to the line number to separate it from whatever follows. The default for char is a tab. Line numbers longer than width columns are truncated.
-o offset
Each line of output is preceded by offset spaces. If the -o option is not specified, the default is zero. The space taken is in addition to the output line width.
-r
Inhibit the warning when a file can't be opened.
-s[char]
Separate text columns by the single character char instead of by the appropriate number of spaces (the default for char is the tab character).
-t
Print neither the five-line identifying header nor the five-line trailer usually supplied for each page. Quit printing 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 -w option is not specified and the -s option is not specified, the default width is 72. If the -w option is not specified and the -s option is specified, the default width is 512.
file
A pathname of a file to be printed. If no file operands are specified, or if a file operand is “-”, the standard input is used.

Description:

The pr utility is a printing and pagination filter for text files. When multiple input files are specified, each is read, formatted, and written to standard output. By default, the input is separated into 66-line pages, each with:

If standard output is associated with a terminal, diagnostic messages are suppressed until the pr utility has completed processing.

When multiple column output is specified, text columns are of equal width. By default text columns are separated by at least one space. Input lines that do not fit into a text column are truncated. Lines are not truncated under single column output.

Exit status:

0
Success.
1
An error occurred.

Errors:

If pr receives an interrupt while printing to a terminal, it flushes all accumulated error messages to the screen before terminating. Error messages are written to stderr during the printing process (if output is redirected) or after all successful file printing is complete (when printing to a terminal).

Contributing author:

Keith Muller

License:

This utility is based on copyright software of The Regents of the University of California; for the copyright notice, see pr in the appendix Third-Party Copyright Notices.

See also:

cat, fold, lpr, more