PG(1) | User Commands | PG(1) |
pg - files perusal filter for CRTs
pg [-number] [-p string] [-cefnrs] [+ linenumber]
[+/ pattern /] [filename]...
The pg command is a filter that allows the examination of filenames one screenful at a time on a CRT. 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, pg scans the terminfo(5) data base for the terminal type specified by the environment variable TERM. If TERM is not defined, the terminal type dumb is assumed.
-number
-pstring
-c
-e
-f
-n
-r
-s
+linenumber
+/pattern/
The following operands are supported:
filename
The responses that may be typed when pg 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>
(+1) l
(+1) d or ^D
if
iz
The following perusal commands take no address.
. or ^L
$
The following commands are available for searching for text patterns in the text. The regular expressions are described on the regex(7) manual page. They must always be terminated by a <newline>, even if the -n option is specified.
i/pattern/
i^pattern^
i?pattern?
After searching, pg will normally display 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
ip
iw
s filename
h
q or Q
!command
At any time when output is being sent to the terminal, the user can hit the quit key (normally CTRL-\) or the interrupt (break) key. This causes pg 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 pg acts just like cat(1), except that a header is printed before each file (if there is more than one).
See largefile(7) for the description of the behavior of pg when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
Example 1 An example of the pg command.
The following command line uses pg to read the system news:
example% news | pg -p "(Page %d):"
See environ(7) for descriptions of the following environment variables that affect the execution of pg: LC_CTYPE, LC_MESSAGES, and NLSPATH.
The following environment variables affect the execution of pg:
COLUMNS
LINES
SHELL
TERM
The following exit values are returned:
0
>0
/tmp/pg*
/usr/share/lib/terminfo/?/*
cat(1), grep(1), more(1), terminfo(5), attributes(7), environ(7), largefile(7), regex(7)
While waiting for terminal input, pg responds to BREAK, CTRL-C, and CTRL−\ by terminating execution. Between prompts, however, these signals interrupt pg'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 /, ^, or ? may be omitted from the searching commands.
If terminal tabs are not set every eight positions, undesirable results may occur.
When using pg as a filter with another command that changes the terminal I/O options, terminal settings may not be restored correctly.
February 25, 1996 | OmniOS |