Writes a file to standard output.
pr [ +Page ] [ -Column [ -a ] | -m ] [ -d ] [ -F ] [ -r ] [ -t ] [ -e [ Character ] [ Gap ] ] [ -h Header ] [ -i [ Character ] [ Gap ] ] [ -l Lines ] [ -n [ Character ] [ Width ] ] [ -o Offset ] [ -s [ Character ] ] [ -w Width ] [ -x [ Character ] [ Width ] ] [ -f ] [ -p ] [ File ... | - ]
The pr command writes the specified file or files to standard output. If you specify the - (minus sign) parameter instead of the File parameter, or if you specify neither, the pr command reads standard input. A heading that contains the page number, date, time, and name of the file separates the output into pages.
Unless specified, columns are of equal width and separated by at least one space. Lines that are too long for the page width are cut off. If standard output is a workstation, the pr command does not display error messages until it has ended.
-Column | Sets the number of columns to the value specified by the Column variable. The default value is 1. This option should not be used with the -m flag. The -e and -i flags are assumed for multicolumn output. A text column should never exceed the length of the page (see the -l flag). When the -Column flag is used with the -t flag, use the minimum number of lines to write the output. |
+Page | Begins the display with the page number specified by the Page variable. The default value is 1. |
-a | Modifies the effect of the -Column flag so that multicolumns are filled horizontally, left to right. For example, if there are two columns, the first input line goes in column 1, the second goes in column 2, the third becomes line 2 of column 1, and so forth. If the -a flag is not specified, columns are created vertically. |
-d | Produces double-spaced output. |
-e[Character][Gap] | Expands tabs to character positions as follows: Gap+1, 2*Gap+1, 3*Gap+1, and so on. The default value of Gap is 8. Tab characters in the input expand to the appropriate number of spaces in order to line up with the next tab setting. If you specify a value for the Character variable (any character other than a digit), that character becomes the input tab character. The default value of the Character variable is the ASCII TAB character. |
-F | Uses a form-feed character to advance to a new page. (Otherwise the pr command issues a sequence of line-feed characters.) Pauses before beginning the first page if the standard output is a workstation. This flag is equivalent to the -f flag. |
-f | Uses a form-feed character to advance to a new page. (Otherwise the pr command issues a sequence of line-feed characters.) Pauses before beginning the first page if the standard output is a workstation. This flag is equivalent to the -F flag. |
-h Header | Uses the specified header string as the page header. If the -h flag is not used, the page header defaults to the file name specified by the File parameter. |
-i[Character][Gap] | Replaces white space wherever possible by inserting tabs to character positions, as follows: Gap+1, 2*Gap+1, and 3*Gap+1, and so forth. The default value of Gap is 8. If you specify a value for the Character variable (any character other than a digit), that character is used as the output tab character. |
-l Lines | Overrides the 66-line default and resets the page length to the number of lines specified by the Lines variable. If the Lines value is smaller than the sum of both the header and trailer depths (in lines), the header and trailer are suppressed (as if the -t flag were in effect). |
-m | Merges files. Standard output is formatted so the pr command writes one line from each file specified by the File parameter, side by side into text columns of equal fixed widths, based on the number of column positions. This flag should not be used with the - Column flag. |
-n[Character][Width] | Provides line numbering based on the number of digits specified by the Width variable. The default is 5 digits. The line number occupies the first Width+1 column positions of each text column of default output, or of each line of output when the -m flag is set. If the Character variable is specified (any non-digit character), it is appended to the line number to separate it from what follows on the line. The default character separator is the tab character. |
-o Offset | Indents each line by the number of character positions specified by the Offset variable. The total number of character positions per line is the sum of the width and offset. The default Offset value is 0. |
-p | Pauses before beginning each page if the output is directed to a workstation. The pr command sounds the alarm at the workstation and waits for you to press the Enter key. |
-r | Does not display diagnostic messages if the system cannot open files. |
-s[ Character ] | Separates columns by the single character specified by the Character variable instead of by the appropriate number of spaces. The default value for the Character variable is an ASCII TAB character. |
-t | Does not display the five-line identifying header and the five-line footer. Stops after the last line of each file without spacing to the end of the page. |
-w Width | Sets the width of 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 is not specified and the -s option is specified, the default width is 512. For single column output, input lines will not be truncated. |
-x[ Character ][ Width ] | |
Provides the same line numbering functions as the -n flag. |
This command returns the following
exit values:
0 | |
All files were successfully written. | |
>0 | An error occurred. |
pr prog.c | qprt
This adds page headings to the prog.c file and sends it to the qprt command. The heading consists of the date the file was last modified, the file name, and the page number.
pr -3 word.lst | qprt
This prints the word.lst file in three vertical columns.
pr -m -h "Members and Visitors" member.lst visitor.lst | qprt
This prints the member.lst and visitor.lst files side by side with the title Members and Visitors.
pr -t -e prog.c > prog.notab.c
This replaces tab characters in the prog.c file with spaces and puts the result in prog.notab.c file. Tab positions are at every eighth column (that is 9, 17, 25, 33, . . .). The -e flag tells the pr command to replace the tab characters; the -t flag suppresses the page headings.
/usr/bin/pr | Contains the pr command. |
/dev/tty* | Suspends messages. |
The cat command, qprt command.
Files Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices describes files, file types, and how to name files.
Input and Output Redirection Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices describes how the operating system processes input and output.
National Language Support Overview for Programming in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs explains collating sequences, equivalence classes, and locale.
Shells Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices describes shells, the different types, and how they affect the way commands are interpreted.
File and Directory Access Modes in AIX 5L Version 5.1 System Management Guide: Operating System and Devices introduces file ownership and permissions to access files and directories.