Module 105 pr

Previous Table of Contents Next


Module 105
pr

DESCRIPTION

The external pr command formats files for printing or displaying. It reads from the standard input or from a list of files and writes to the standard output. The input is reformatted according to specified options. The formatting is page and file oriented. Textual type formatting, as done by troff , is not performed by pg . The output can be reformatted to multiple columns , with or without headers and footers, indented, and double spaced , among various other formats.

COMMAND FORMAT

Following is the general format of the pr command.

 pr [ [ -col ] [ -wwid ] [ -a ] ] [ +p ] [ -dfprt ] [ -eck ]       [ -hhdr ] \ [ -ick ] [ -llen ] [ -nck ] [ -ooffset ]       [ -sc ] [ -F ] [ filelist ] \ [ - ]      pr [ [ -m ]   [ -wwid ]        ] [ +p ] [ -dfprt ] [ -eck ]       [ -hhdr ] \ [ -ick ] [ -llen ] [ -nck ] [ -ooffset ]       [ -sc ] [ -F ] [ file_list ] \ [ - ] 

The first format is used to specify the number of columns (-col) to display on the output. The second format displays the output based on the number of input files. If you have three input files, the output is displayed in three columns. The - col option and the -m option are mutually exclusive; that is, you can only use one or the other on the same command line.


BSD (Berkeley)
pr [ -col ] [ +p ] [ -f ] [ -hhdr ] [ -llen ] [ -m ] [ -sc ]
[ -t ] \ [ -wwid ] [ file_list ]
The - col option does not appear to work on some BSD type systems.

Options

The following list describes the options and their arguments that may be used to control how pr functions.

+ p Begins displaying text at page p. The p must be an integer. The page numbers are based on the -l and -h options. The default number for p is 1. For example,
 pr +5 infile 
skips the first 226 (4 pages * 56 lines per page) lines of input and displays the fifth page of input.
- col Displays the output in col columns. The -e and -i options are assumed. This option cannot be used in conjunction with the -m option. The input is displayed down the first column of output then down the second column. This process is repeated for each page of output. The column widths vary depending on the page width and number of columns requested . By default, input lines that are too long to be displayed in the column are truncated. For example,
 pr -4 infile                      data         data          data         data                      .                      . 
displays the data in 4 columns; each page has a header.
-a Displays multicolumn output (- col option) across the columns instead of down the columns. The first line of input goes in column one, the second line goes in column two, and so on. This option can only be used with the - col option.
-d Double space the output. Blank lines at the top of the page are dropped.
-e ck Expands input character c to k positions in the output. The default for c is a tab. The c must be a nondigit. The default number for k is 8. Therefore, the tab positions are set to 1, 9, 17, and so on. You can omit either the c or the k or both. If k is given, the output tab positions are set to k + 1, 2 * k + 1, and so on. For example, if you specify
 pr -e:20 infile 
each : (colon) found in the input line is expanded to the next tab position that is a multiple of 20. The character following the first colon is placed in column 21 if possible.
-f Use form feed character (Ctrl-L) for new pages. Normally a sequence of new-lines are used to eject a page. A pause occurs before the first page is printed. You MUST press Return to have pr continue.
-F Fold the input lines to fit the current line width. If used with the -a or -m options for multicolumn output lines will be folded to fit the current columns width.
-h hdr Use hdr as the text for the header instead of the filename. The -h option is ignored if the -t option is specified or the -l option is specified with a len gth of 10 or less. The -h must be followed by a space. The hdr may be enclosed in quotes if it contains blanks. For example,
 pr -h "infile - Please deliver to mylogin" infile 
places the message infile-Please deliver to mylogin on the top of each page.
-i ck Tabs replace spaces in the output where possible. The default for c is a tab. The c must be a nondigit. The default for k is 8; therefore, tab positions are set at 1, 9, 17, and so on. If k is given, then tab positions are set at k + 1, 2 * k + 1, and so on.
-l len Set the page length to len lines. The default is 66 lines. A len of zero (0) is reset to 66. If len is less than 10 then the -t option is assumed and the header and trailers are suppressed. If the headers and trailers are not suppressed, the actual lines of text displayed per page is len - 10. The header and trailer require 10 lines per page. Thus a normal page only displays 56 lines of text.
-m Merges and displays all input files simultaneously in multiple columns. Each input file is displayed in its own column. The most files you can specify is eight. If lines are longer than the width of the column, they are truncated. The -m option cannot be used with the - col or -a options.
-n ck Generates numbered output lines. The line numbers are formatted in k spaces. The default for k is five. If c is specified, then the line number is separated from the text by character c.
-o offset Offset (indent) each line by offset characters . The default of offset is zero (0).
-p Pauses before displaying the next page of output. The output must be to your terminal screen. Your terminal s bell is sounded and pr waits for you to press Return before displaying the next page.
-r No diagnostic warning messages are displayed if a problem occurs while pr is attempting to open a file.
-s c Separate columns of output with the character c instead of the appropriate number of spaces used for normal formatting. The default character for c is the tab. Multicolumn output is not truncated unless the -w option is specified.
-t Suppress the headers and trailers. The normal header has two blank lines: an information line followed by two more blank lines. The information line contains the Month, Day, Time, Year, Filename, and Page number. The trailer consists of five blank lines. The -t option causes the -h option to be ignored.
-w wid Sets the width of the output line to wid characters. The normal width is 72 characters. This option only affects multicolumn output (- col and -m options).
If no options are specified, a header and footer are added to each page of output. The header consist of five lines, with the third line containing the Month, Day, Time, Year, Filename, and Page number. The footer is five blank lines. For example,
 pr infile 
produces
 Mar  16 06:57 1989 infile Page 1                      First line of input.                      @LINE= 
BSD (Berkeley)
The supported options under BSD function the same as the corresponding SV options.


Previous Table of Contents Next

Copyright Wordware Publishing, Inc.


Illustrated UNIX System V
Illustrated Unix System V/Bsd
ISBN: 1556221878
EAN: 2147483647
Year: N/A
Pages: 144
Authors: Robert Felps

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net