pg 1 "28 Mar 1995"

Table of contents


pg 1 "28 Mar 1995"

NAME

pg - files perusal filter for CRTs

SYNOPSIS

pg [ -number ] [ -p string ] [ -cefnrs ] [ +linenumber ] [ +/pattern/ ] [ filename ... ]

AVAILABILITY

SUNWcsu


DESCRIPTION

The \f3pg command is a filter that allows the examination of filenames one screenful at a time on a \s-1CRT\s+1. If the user types a RETURN, another page is displayed; other possibilities are listed below.

This command is different from previous paginators in that it allows you to back up and review something that has already passed. The method for doing this is explained below.

To determine terminal attributes, \f3pg scans the terminfo(4) data base for the terminal type specified by the environment variable \f3TERM\f1. If \f3TERM\f1 is not defined, the terminal type \f3dumb\f1 is assumed.


OPTIONS

-number
An integer specifying the size (in lines) of the window that \f3pg is to use instead of the default. (On a terminal containing 24 lines, the default window size is 23).
-p string
pg uses string as the prompt. If the prompt string contains a \f3%d, the first occurrence of \f3%d in the prompt will be replaced by the current page number when the prompt is issued. The default prompt string is ``\f3:\f1''.
-c
Home the cursor and clear the screen before displaying each page. This option is ignored if \f3clear_screen\f1 is not defined for this terminal type in the terminfo(4) data base.
-e
pg does not pause at the end of each file.
-f
Normally, \f3pg splits lines longer than the screen width, but some sequences of characters in the text being displayed (for instance, escape sequences for underlining) generate undesirable results. The -f option inhibits \f3pg from splitting lines.
-n
Normally, commands must be terminated by a <newline> character. This option causes an automatic end of command as soon as a command letter is entered.
-r
Restricted mode. The shell escape is disallowed. \f3pg prints an error message but does not exit.
-s
pg prints all messages and prompts in the standard output mode (usually inverse video).
+linenumber
Start up at linenumber.
+/pattern/
Start up at the first line containing the regular expression pattern.

OPERANDS

The following operands are supported:
\f2filename\f1
A path name of a text file to be displayed. If no filename is given, or if it is -, the standard input is read.

USAGE

Commands

The responses that may be typed when \f3pg pauses can be divided into three categories: those causing further perusal, those that search, and those that modify the perusal environment.

Commands that cause further perusal normally take a preceding address, 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>
This causes one page to be displayed. The address is specified in pages.
\f1(+1) \f3l\f1
With a relative address this causes \f3pg to simulate scrolling the screen, forward or backward, the number of lines specified. With an absolute address this command prints a screenful beginning at the specified line.
\f1(+1) \f3d\f1 or \f3^D\f1
Simulates scrolling half a screen forward or backward.
\f2i\f1\f3f\f1
Skip i screens of text.
\f2i\f1\f3z\f1
Same as <\f2newline\f1> except that i, if present, becomes the new default number of lines per screenful.

The following perusal commands take no address.

\f3.\f1 or \f3^L\f1
Typing a single period causes the current page of text to be redisplayed.
\f3$\f1
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 are described on the regexp(5) manual page. They must always be terminated by a <newline>, even if the -n option is specified.

\f2i\f1\f3/\f1\f2pattern\f1\f3/\f1
Search 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.

\f2i\f1\f3^\f1\f2pattern\f1\f3^\f1
\f2i\f1\f3?\f1\f2pattern\f1\f3?\f1
Search 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 ^ notation is useful for Adds 100 terminals which will not properly handle the ?.

After searching, \f3pg will normally display the line found at the top of the screen. This can be modified by appending \f3m\f1 or \f3b\f1 to the search command to leave the line found in the middle or at the bottom of the window from now on. The suffix \f3t\f1 can be used to restore the original situation.

The user of \f3pg\f1 can modify the environment of perusal with the following commands:

\f2i\f1\f3n\f1
Begin perusing the ith next file in the command line. The i is an unsigned number, default value is 1.
\f2i\f1\f3p\f1
Begin perusing the ith previous file in the command line. i is an unsigned number, default is 1.
\f2i\f1\f3w\f1
Display another window of text. If i is present, set the window size to i.
\f3s \f1\f2filename\f1
Save the input in the named file. Only the current file being perused is saved. The white space between the \f3s\f1 and filename is optional. This command must always be terminated by a <newline>, even if the -n option is specified.
\f3h\f1
Help by displaying an abbreviated summary of available commands.
\f3q\f1 or \f3Q\f1
Quit \f3pg\f1.
\f3!\f1\f2command\f1
Command is passed to the shell, whose name is taken from the \f3SHELL\f1 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 \s-1CTRL\s+1-\) or the interrupt (break) key. This causes \f3pg to stop sending output, and 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 \f3pg acts just like cat(1), except that a header is printed before each file (if there is more than one).


EXAMPLES

The following command line uses pg to read the system news:

\f3example% news | pg -p "(Page %d):"\f1

ENVIRONMENT

See environ(5) for descriptions of the following environment variables that affect the execution of pg: LC_CTYPE\f1, LC_MESSAGES\f1, and NLSPATH\f1.

The following environment variables affect the execution of pg:

.SB COLUMNS
Determine the horizontal screen size. If unset or use the value of the window size, baud rate, or some combination of these, to indicate the terminal type for the screen size calculation.
.SB LINES
Determine the number of lines to be displayed on the screen. If unset or use the value of the window size, baud rate, or some combination of these, to indicate the terminal type for the screen size calculation.
.SB SHELL
Determine the name of the command interpreter executed for a !command.
.SB TERM
Determine terminal attributes. Optionally attempt to search a system-dependent database, keyed on the value of the environment variable. If no information is available, a terminal incapable of cursor-addressable movement is assumed.

EXIT STATUS

The following exit values are returned:
0
Successful completion.
>0
An error occurred.

FILES

/tmp/pg*
temporary file when input is from a pipe
/usr/share/lib/terminfo/?/\(**
terminal information database

SEE ALSO

cat(1), grep(1), more(1), terminfo(4), environ(5), regexp(5)

NOTES

While waiting for terminal input, \f3pg responds to \s-1BREAK\s+1, \s-1CTRL-C\s+1, and \s-1CTRL-\s+1 by terminating execution. Between prompts, however, these signals interrupt \f3pg'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.

The terminal \f3/\f1, \f3^\f1, or \f3?\f1 may be omitted from the searching commands.

If terminal tabs are not set every eight positions, undesirable results may occur.

When using \f3pg as a filter with another command that changes the terminal I/O options, terminal settings may not be restored correctly.