pr Command Purpose Writes a file to standard output. Syntax pr [ -d ] [ -f ] [ -F ] [ -p ] [ -r ] [ -t ] [ +Page ] [ { -m | -Column { -a | [ -i [ Character ] [ Gap ] ] [ -e [ Character ] [ Gap ] } } ] [ -h" String" ] [ -lLines ] [ -n [ Character ] [ Width ] ] [ -oOffset ] [ -sCharacter ] [ -wWidth ] [ File ... | - ] Description The pr command writes the specified file or files to standard output. If you specify the - (minus sign) flag 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. Flags - Reads standard input. Use this flag only if you do not specify the File parameter. If you specify neither, the pr command reads standard input. -a Displays multicolumn output across the page. This flag is only appropriate with the -Column flag set. -d Double-spaces the output. -e[Character][Gap] Expands tabs to character positions as fol- lows: 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 charac- ter. The default value of the Character variable is the ASCII TAB character. -F Uses a form-feed character to advance to a new page. (Other- wise the pr command issues a sequence of line-feed char- acters.) 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. (Other- wise the pr command issues a sequence of line-feed char- acters.) Pauses before beginning the first page if the standard output is a workstation. This flag is equivalent to the -F flag. -h "String" Displays the specified string, enclosed in " " (quotes), instead of the file name as the page header. The flag and string should be separated by a space. -i[Character][Gap] Replaces white space wherever possible by in- serting 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 charac- ter. -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 a File variable, 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[Width][Character] Provides line numbering based on the number of digits specified by the Width variable. The default is 5 di- gits. The line number occupies the first Width+1 column posi- tions of each text column of default output or of each line of output when the -m flag is set. If the Character (any non-digit character) variable is specified, 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 de- fault value of Offset is 0. -p Pauses before beginning each page if the output is directed to a workstation. The pr command sounds the alarm at the worksta- tion and waits for you to press the Enter key. -r Does not display diagnostic messages if the system cannot open files. -sCharacter Separates columns by the single character specified by the Character variable instead of by the appropriate number of spaces. The default value for Character is an ASCII TAB charac- ter. -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. -wWidth Sets the number of column positions per line to the value specified by the Width variable. The default value is 72 for equal-width multicolumn output. There is no limit otherwise. If the -w flag is not specified and the -s flag is specified, the default width is 512 column positions. -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 this 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. Exit Status This command returns the following exit values: 0 All files were successfully written. >0 An error occurred. Examples 1. To print a file with headings and page numbers on the printer, enter: pr prog.c | qprt This adds page headings to prog.c and sends it to the qprt com- mand. The heading consists of the date the file was last modi- fied, the file name, and the page number. 2. To specify a title, enter: pr -h "MAIN PROGRAM" prog.c | qprt This prints prog.c with the title MAIN PROGRAM in place of the file name. The modification date and page number are still printed. 3. To print a file in multiple columns, enter: pr -3 word.lst | qprt This prints the word.lst file in three vertical columns. 4. To print several files side by side on the paper: pr -m -h "Members and Visitors" member.lst visitor.lst | qprt This prints member.lst and visitor.lst side by side with the ti- tle Members and Visitors. 5. To modify a file for later use, enter: pr -t-e prog.c > prog.notab.c This replaces tab characters in prog.c with spaces and puts the result in prog.notab.c. Tab positions are at columns 9, 17, 25, 33, . . . . The -e flag tells the pr command to replace the tab characters; the -t flag suppresses the page headings. Implementation Specifics This command is part of Base Operating System (BOS) Runtime. Files /usr/bin/pr Contains the pr command. /dev/tty* Suspends messages. Related Information The cat command, qprt command. Files Overview in AIX Version 3.2 System User's Guide: Base and Devices describes files, file types, and how to name files. Understanding File and Directory Access Modes in AIX Version 3.2 System Management Guide: Operating System and Devices introduces file ownership and permissions to access files and directories. Input and Output Redirection Overview in AIX Version 3.2 System User's Guide: Base and Devices describes how the operating system processes input and output. National Language Support Overview for Programming in AIX Ver- sion 3.2 General Programming Concepts explains collating se- quences, equivalence classes, and locale. Shells Overview in AIX Version 3.2 System User's Guide: Base and Devices describes shells, the different types, and how they af- fect the way commands are interpreted.