pg(1) General Commands Manual pg(1)
NAME
pg - Formats files for a terminal display
SYNOPSIS
pg [-cefns] [-p string] [+line_number | +/pattern/] [-number] [file...]
The pg command reads the specified file or files (or standard input by default) and writes them to standard output one screen at a time.
At the end of each screen you can display the next screen or enter various subcommands, including those that let you back up to review
something that has already passed.
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
pg: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Moves the cursor to the home position and clears the is not defined for your terminal type in the terminfo file. Does not pause at the end
of each file. However, pg still pauses at the beginning of each file. Does not split lines. Normally, pg splits (wraps) lines longer
than the screen width. Stops processing when a pg command letter is entered. Normally, commands must end with a newline character. Uses
string as the prompt. If the string contains %d, %d is replaced by the current page number in the prompt. The default prompt is :
(colon). If string contains spaces, you must quote it. In addition, if string contains either the < or > characters, you must quote it;
otherwise, these characters are treated as shell redirection commands. Highlights all messages and prompts. Starts at line_number. Spec-
ifies the number of lines in the window. Starts at the first line that contains pattern.
OPERANDS
The name of a file to be read and displayed. If you specify file as a - (dash) or run pg without arguments, pg reads standard input.
DESCRIPTION
To determine terminal attributes, pg looks up the terminal type specified by the TERM environment variable in the terminfo database. The
default type is dumb.
At any time during the operation of pg, you can enter the Quit (usually <Ctrl-> ) or Interrupt (usually <Ctrl-c>) key sequences. If pg is
sending output, it interrupts output and displays the prompt, and you can then enter one of the subcommands in the normal manner. If the
prompt is already displayed, the Quit and Interrupt sequences terminate pg. (Note that on a high-speed display it may be difficult to
enter a Quit or Interrupt between prompts, because the interval between them is so short.)
Note that some output is lost when you use the Quit or Interrupt sequences during output because any characters waiting in the output queue
are purged when the QUIT or INTERRUPT signal is received. When you use pg in a pipe, an Interrupt is likely to end the other commands in
the pipe.
If standard output is not a terminal, pg acts like the cat command, writing the input to standard output without any formatting or special
treatment, except that a header is displayed before each file.
If terminal tabs are not set for every eight positions, unpredictable results can occur.
NOTES
The pg utility is marked LEGACY in XCU Issue 5.
SUBCOMMANDS
When pg pauses and displays its prompt, you can enter a subcommand. Some of these subcommands change the display to a particular place in
the file, some search for specific patterns in the text, and others change the environment in which pg works.
Location Subcommands
The following commands display a selected place in the file: Displays page number number. Displays the page number pages after the current
page. Displays the page number pages before the current page. Scrolls the display one line forward. [Tru64 UNIX] Displays a screen with
the specified line number at the top. Scrolls the display number lines forward. Scrolls the display number lines backward. Scrolls half
a screen forward. Pressing <Ctrl-d> (and <Return> if you have not specified -n) has the same effect. Scrolls half a screen backward.
Pressing - and then <Ctrl-d> (and <Return> if you have not specified -n) has the same effect. [Tru64 UNIX] Skips number screens forward.
[Tru64 UNIX] Skips number screens backward. Displays the current page again. A single (dot) also does this. Displays the last page in
the file. Do not use this when the input is from a pipeline.
Search Subcommands
The following commands search for patterns in the text. You can use the regular expressions described in grep. They must always end with a
newline character, even if the -n option is used. In an expression such as [a-z], the dash means through according to the current collat-
ing sequence. The collating sequence is determined by the value of the LC_COLLATE environment variable. Searches for the number'th occur-
rence of pattern. The search begins immediately after the current page and continues to the end of the current file, without wrapping
around. The default for number is 1. Searches backward for the number'th occurrence of pattern. The search begins immediately before the
current page and continues to the beginning of the current file, without wraparound. The ^ (circumflex) is useful for the Adds 100 termi-
nal, which cannot handle a ? (question mark). The default for number is 1.
After searching, pg normally displays the line found at the top of the screen. You can change this by adding m or b to the search command
to leave the line found in the middle or at the bottom of the window with all succeeding subcommands. Use the suffix t to return to dis-
playing the line with the pattern to the top of the screen.
Environment Subcommands
You can change the pg environment with the following subcommands: Begins examining the number'th next file in the command line. The
default number is 1. Begins examining the number'th previous file on the command line. The default number is 1. Sets the window size to
number. If number is not present, displays another window of text. Same as w. Saves the input in file. Only the current file being
examined is saved. This command must always end with a newline character, even if you specify the -n option. Displays an abbreviated sum-
mary of available subcommands. Quits pg. Sends the specified command to the shell named in the SHELL environment variable. If this is
not available, the default shell is used. This command must always end with a newline character, even if the -n option is used.
EXIT STATUS
The following exit values are returned: Successful completion. An error occurred.
EXAMPLES
To look at the contents of file file1 one page at a time, enter: pg file1
ENVIRONMENT VARIABLES
The following environment variables affect the execution of pg: Determines the horizontal screen size. If this variable is unset, TERM is
used. Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding
value from the default locale is used. If any of the internationalization variables contain an invalid setting, the utility behaves as if
none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization
variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
opposed to multibyte characters in arguments) and the behavior of character classes in regular expressions. Determines the locale for the
format and contents of diagnostic messages written to standard error. Determines the number of lines to be displayed on the screen. If
this variable is unset, TERM is used. Determines the location of message catalogues for the processing of LC_MESSAGES. Determines the
name of the command interpreter executed for a ! subcommand. Determines the terminal attributes.
FILES
Terminal capability database. Temporary file used when input is from a pipe.
SEE ALSO
Commands: cat(1), grep(1), more(1)
Files: locale(4) terminfo(4)
Standards: standards(5)
pg(1)