pg(1)
NAME
pg − file perusal filter for soft-copy terminals
SYNTAX
pg [−number] [−p string] [−cefs] [+linenumber] [+/pattern/] [files...]
DESCRIPTION
The pg command is a filter that allows the examination of files one screenful at a time on a soft-copy terminal. When the file name is designated by an en dash (−) and/or NULL argument, the pg command reads from the standard input Each screenful is followed by a prompt. If the user types a carriage return, another page is displayed.
This command is different from previous paginators because it allows you to back up and review material that has already passed.
In order to determine terminal attributes, pg scans the terminfo() data base for the terminal type specified by the environment variable TERM. If TERM is not defined, the terminal is assumed to be a dumb terminal. The pg command takes responses that can be divided into three categories: those causing further perusal, those that search, and those that modify the perusal environment.
Commands causing further perusal normally take a preceding address, which is an optionally signed number indicating the point from which further text should be displayed. This address is interpreted in either pages or lines depending on the command. A signed address specifies a point relative to the current page or line, and an unsigned address specifies an address relative to the beginning of the file. Each command has a default address that is used if none is provided.
The perusal commands and their defaults are as follows:
(+1)<newline> or <blank>
Causes one page to be displayed. The address is specified in pages.
(+1) l Causes pg to simulate scrolling the screen, forward or backward, the number of lines specified when used with a relative address. With an absolute address this command prints a screenful beginning at the specified line.
(+1) d or ^D Simulates scrolling half a screen forward or backward.
The following perusal commands take no address:
. or ^L Causes the current page of text to be redisplayed.
$ Displays the last windowful in the file. Use with caution when the input is a pipe.
The following commands are available for searching for text patterns in the text. The regular expressions described in ed() are available. They must always be terminated by a <newline>, even if the −n option is specified.
i/pattern/ Searches forward for the ith (default i=1) occurrence of pattern. Searching begins immediately after the current page and continues to the end of the current file, without wrap-around.
i^pattern^
i?pattern?
Searches backwards for the ith (default i=1) occurrence of pattern. Searching begins immediately before the current page and continues to the beginning of the current file, without wrap-around. The circumflex (^) notation is useful for Adds 100 terminals which do not handle the question mark (?) properly.
After searching, pg normally displays the line found at the top of the screen. This can be modified by appending m or b to the search command to leave the line found in the middle or at the bottom of the window from now on. The suffix t can be used to restore the original situation.
The user of pg can modify the environment of perusal with the following commands:
in Begins perusing the ith next file in the command line. The i is an unsigned number. Default value is 1.
i Begins perusing the ith previous file in the command line. i is an unsigned number. Default is 1.
iw Displays another window of text. If i is present, sets the window size to i.
s filename Saves the input in the named file. Only the current file being perused is saved. The white space between the s and filename is optional. This command must always be terminated by a <newline>, even if the −n option is specified.
h Helps by displaying an abbreviated summary of available commands.
q or Q Quits pg.
!command The command is passed to the shell, whose name is taken from the SHELL environment variable. If this is not available, the default shell is used. This command must always be terminated by a <newline>, even if the −n option is specified.
At any time when output is being sent to the terminal, the user can hit the quit key (normally control-\) or the interrupt (break) key. This causes pg to stop sending output and to display the prompt. The user may then enter one of the above commands in the normal manner. Unfortunately, some output is lost when this is done, because any characters waiting in the terminal’s output queue are flushed when the quit signal occurs.
If the standard output is not a terminal, then pg acts just like cat(,), except that a header is printed before each file (if there is more than one).
OPTIONS
The command line options are:
−number Specifies the size (in lines) of the window that pg is to use instead of the default. (On a terminal containing 24 lines, the default window size is 23).
−p string Causes pg to use string as the prompt. If the prompt string contains a %d, the first occurrence of %d in the prompt is replaced by the current page number when the prompt is issued. The default prompt string is designated by a colon (:).
−c Homes the cursor and clears the screen before displaying each page. This option is ignored if clear_screen is not defined for this terminal type in the terminfo() data base.
−e Causes pg not to pause at the end of each file.
−f Inhibits pg from splitting lines. Normally, pg splits lines longer than the screen width, but some sequences of characters in the text being displayed (for example, escape sequences for underlining) generate undesirable results. The −f option prevents the splitting of these sequences.
−s Causes pg to print all messages and prompts in standout mode (usually inverse video).
+linenumber Starts up at linenumber.
+/pattern/ Starts up at the first line containing the regular expression pattern.
EXAMPLE
The following example shows how the pg command is used reading system news:
news | pg -p "(Page %d):"
NOTES
While waiting for terminal input, pg responds to BREAK, DEL and the circumflex (^) by terminating execution. Between prompts, however, these signals interrupt pg command’s current task and place the user in prompt mode. These should be used with caution when input is being read from a pipe, since an interrupt is likely to terminate the other commands in the pipeline.
RESTRICTIONS
Terminal tabs must be set every eight positions.
Using pg as a filter with another command changes the terminal I/O options. For example, crypt(,), terminal settings may not be restored correctly.
FILES
/usr/lib/terminfo/* Terminal information data base
/tmp/pg* Temporary file when input is from a pipe