pr

display and format files 

Command


SYNOPSIS

pr [-adFfmprtW] [-c n] [-e[char][gap]] [-H header-fmt] [-h header] [-i[char][gap]] [-l n] [-n[char][n]] [-o n] [-s[char]] [-w n] [+n] [-n] [file ...]


DESCRIPTION

pr displays the specified files on the standard output in a paginated form. If you do not specify any files or you specify a file name of -, pr reads the standard input. By default, pr formats the given files into single-column 66-line pages. Each page has a 5-line header. By default, the third line contains the file's path name, its date of last modification and the current page number; the other lines are blank. A 5-line trailer consists of blank lines.

If you specify multiple columns, pr places its output in columns of equal width separated by at least one space, truncating each line to fit in its column. Input lines may be ordered down the columns or across the page on output; or different columns may each represent different files.

Options

+n 

starts displaying with the nth page of each file. The default for n is 1.

-n 

displays n columns of output. This is the obsolete equivalent of -c n.

-a 

orders input lines across the page on output, instead of down. You should only use this option with -n.

-c n 

displays n columns of output. When you specify this option, pr behaves as though you had also specified the -e and -i options. When you specify both this option and -t, pr uses the minimum number of lines possible to display the output. You should not specify this option with -m.

-d 

produces double-spaced output.

-e[char][gap

expands each occurrence of the input tab character to a string of spaces such that the following character has the next column position which is a positive multiple of gap, plus 1. If you do not specify gap, or if it is zero, pr assumes that gap has the value of eight. If you specify the nondigit character char, pr treats it as the input tab character; otherwise, pr uses the standard tab character.

-F 

uses formfeeds to separate pages. pr normally separates pages by sending a series of newline characters to fill the length of a page.

-f 

uses formfeeds to separate pages. When output is to a terminal, pr sounds the bell and waits for you to type a carriage return before displaying the text. pr normally separates pages by sending a series of newline characters to fill the length of a page.

-H header_fmt 

lets you customize your header line by specifying a format with the string header_fmt. pr recognizes the following special formatting commands:

%c 
date and time
%F 
current file name, or header string given by -h
%P 
page number
%L 
line number
%D 
date
%T 
time
%u 
current user name

The default header format is equivalent to the option:

-H "%c  %F  Page %P"
-h header uses the header string instead of the file name on each succeeding page header.
-i[char][gap

replaces white space with tabs on output. The nondigit character char, if given, is the output tab character. The default is the tab character. If this tab character differs from the input tab character, and the actual data contains this tab character, the result is liable to be quite a mess. pr sets tabs every gap positions; the default for gap is eight.

-l n 

sets the number of lines per page of output; the default is 66. The actual number of lines displayed per page is this number less 5 for the header and 5 for the trailer. If n is less than 10 (the number of lines needed for the header and the trailer), pr displays neither the header nor the trailer.

-m 

displays each file in its own column down the page. This overrides the -a option, forcing the -n option to be the number of files given. When you also specify the -n option, it gives line numbers for the first column only.

-n[char][n

numbers the lines of each file. Each number takes up n positions; the default for n is 5. The character char separates the number from the line; this defaults to the tab character. For multi-column output, pr adds line numbers to each column. If more than one column is displayed the -m option gives the line number for the first column only.

-o n 

precedes each line of output with n spaces.

-p 

pauses before the beginning of each page if output is to a terminal device. pr sounds the bell and waits for a carriage return from the controlling terminal (not the input files).

-r 

suppresses error messages due to failures when opening files.

-s[char

separates text columns with the single character char instead of the appropriate number of spaces. The default value for char is the tab character. Normally pr pads each column with spaces or truncates it to the exact column width. Unless the -w option is also used, -s resets the page width to 512 column positions.

-t 

does not display the headers and trailers, and quits after the last line of the file--it does not display any extra lines.

-W 

folds lines at the column width; pr treats each separate part of the line as a separate line.

-w n 

sets the width of the page to n column positions. Without this option, the default page width is 72 (if you did not specify -s) or 512 (if you did specify -s.). This page width does not normally apply to single column output; however, single column output with the -W option does use this width.


ENVIRONMENT VARIABLES

TZ 

contains the local time zone. pr uses this value when displaying times in header lines.


FILES

/dev/tty 

for prompting (UNIX and POSIX-compliant systems only)

CON: 

for prompting (Windows 95/98/Me)

CONIN$ 

for prompting (8.1/2012R2/10/2016/2019/11/2022)


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

Failure due to any of the following:

— insufficient memory
— insufficient line width
— write error on the standard output
2 

Syntax error or unknown command line option.

Missing header 

You specified -h or -H but did not supply a header or header_fmt string.

Width is insufficient 

The line is not wide enough to hold the given number of columns with the given column width; or a column is not wide enough to hold the minimum amount of data.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.

This version of pr is compatible with the UNIX System V version of the command, which differs substantially from versions of pr found in earlier UNIX releases.

The -c, -H, -p, and -W options are extensions to the POSIX standard. The -H and -W options are extensions to the XPG standard.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Commands:
c, cat, expand, fold, unexpand


PTC MKS Toolkit 10.4 Documentation Build 39.