Formatting files for printing (pr command)
You can use the pr command to perform simple formatting of files that are sent to a printer.
You can pipe the output of the pr command to the qprt command to format your text.
Some
useful pr command flags are:
Item | Descriptor |
---|---|
-d | Double-spaces the output. |
-h " String" | Displays the specified string, enclosed in quotes
(" " ), instead of the file name as the page header.
Separate the flag and string by a space. |
-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 digits. If the Character (any nondigit 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 ASCII 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 value of Offset is 0. |
-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 Character 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 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. Do not use this option 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. |
For the complete syntax, see the pr command in in Commands Reference.
The
following is a list of examples of how pr command
flags can be used:
- To print a file named prog.c with headings
and page numbers on the printer, type:
This command adds page headings to prog.c 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 prog.c | qprt
- To specify a title for a file named prog.c,
type:
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. - To print a file named word.lst in multiple
columns, type:
pr -3 word.lst | qprt
This prints the word.lst file in three vertical columns.
- To print several files side by side on the paper, type:
This prints member.lst and visitor.lst side by side with the title Members and Visitors.pr -m -h "Members and Visitors" member.lst visitor.lst | qprt
- To modify a file named prog.c for later use,
type:
This command 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, and so on. The -e flag tells the pr command to replace the tab characters; the -t flag suppresses the page headings.pr -t -e prog.c > prog.notab.c
- To print a file named myfile in two columns,
in landscape, and in 7-point text, type:
pr -l66 -w172 -2 myfile | qprt -z1 -p7