Format
pg [–cefnst]
[–p prompt] [– screen]
[+line] [+/pattern/]
[file …]
The pg utility
is fully supported for compatibility with older UNIX systems.
However, it is recommended that the more utility
be used instead because it may provide greater functionality and is
considered the standard for portable UNIX applications
as defined by POSIX.2 IEEE standard 1003.2-1992.
Description
pg displays
input files or piped output from another command, a screen at a time. If you do not specify
any files, the standard input (stdin) is read. Any file named – specifies
the stdin.
Commands lists commands
that can be entered at page and file breaks.
Options
- –c
- Clears the screen before displaying each new window.
- –e
- Eliminates the (EOF): prompt at the end of each
file.
- –f
- Does not fold lines. Typically, lines longer than the screen width,
as given by the environment variable COLUMNS are folded into
multiple lines. This option
may be useful for files containing device-specific escape sequences.
- –n
- Executes interactive commands immediately after receiving the
command character. This works for most commands. Typically, you must
press <Enter> for interactive commands.
- –p string
- Sets the prompt string that appears at the end of each screen
of text to string. The default prompt is
a colon (:). If string contains
the characters %d, pg replaces
those characters with the current page number as in [Page %d].
- –s
- Displays all interactive command prompts in standout mode (most
often reverse video) on the screen.
- –t
- Does not save input in a temporary file. Typically, if any of
the inputs is not directly seekable (as is the case for a serial device
or pipe), pg reads input and saves it in
a temporary file so that it can be reviewed. Because of this, you
cannot scan backwards when viewing such input. This option is also
recommended when reading a larger amount of data from a stream that
cannot be accommodated on disk.
- –screen
- Sets the number of lines displayed in each screen to n lines.
If you do not select this option, the number of lines displayed is
one less than the number of lines on the screen as given by the environment
variable LINES. Commands discusses the w command.
- +line
- Starts printing at line n of the first
file. The default is to start printing at line 1.
- +/pattern/
- Starts printing at the line containing the first occurrence of
the extended regular expression pattern.
See Regular expressions (regexp) for more information
about regexp.
Commands
Depending on the options
you specify, pg pauses between windows (screens)
of text, at the end of each file and before starting any file after
the first. At these pauses, pg prompts you
to enter a command. To read the file, type the command ENTER (newline
or Return) at each prompt.
An optional sign (+ or –)
followed by an optional numeric address can precede the following
commands. Addresses work in multiples of screen displays: for example,
an address of +2 displays the second next screen.
Typically, an unsigned address implies direct addressing (measured
from the beginning of the file). A signed address implies relative
addressing in the file; a command beginning with a + scans
forward and one beginning with a – scans
backward from the current position.
You can edit commands interactively
with the standard erase and kill characters.
These are the
interactive commands:
- h
- Prints a summary of the interactive commands.
- q, Q
- Exits immediately from pg.
- !command
- Executes the string command as if it
were typed to the default command interpreter (as in ed).
Whether or not you specified the –n option,
you must end this command with a newline.
- [[±]n] ENTER, [[±]n] SPACEBAR
- Without a specified address, displays the next window of text.
With an address, displays the nth next window
of text.
- [[±]n]d,
[[±]n]CRTL–D
- Scrolls a half screen of text. The address is measured in half
screens and defaults to the next half screen.
- [[±]n]l
- With no address, displays the next line of the file. With an address,
it displays a screen starting at the addressed line.
- $
- Displays the last screen of text in the file.
- <Ctrl-L>, .
- Redisplays the current displayed window of text.
- s file
- Saves the entire contents of the current file in file.
Whether or not you specified the –n option,
you must end this command with a newline.
- [n] n
- Displays the first screen of the next file. The address (n)
is actually the nth next file, counting
from the current file. If present, n must
be unsigned.
- [n] p
- Displays the first screen of the previous file. The address (n)
is actually the nth previous file, counting
from the current file. If present, n must
be unsigned.
- [n] w
- Scrolls another window of text. The argument, n (which
must be unsigned), sets the window size to n and
displays the next window of text.
- [i]/pattern/[tmb]
- Searches forward within the current file for the ith
next occurrence of a line matching the regular expression pattern (default i is
1, the next matching pattern). The search starts right after the current
window and continues to the end of the file. Typically, the matching
line is displayed at the top of the window, but this can be changed
by an optional character at the end of the search command. The letter t is
the default and displays the line at the top of the window, m displays
it in the middle of the window, and b displays it
in the bottom of the window. When no letter is present, pg uses
the last letter entered (or .t if no letter has been
entered). Whether or not you specified the –n option,
you must end this command with a newline.
- [i]?pattern?[tmb],
[i]^ pattern^[tmb]
- Is similar to the previous command, but searches backward instead
of forward. The search starts just before the current window.
Examples
The following interactive commands
illustrate the flexibility of
pg. Suppose
you enter the command:
pg –n *.c
and that
there are a large number of source files in the current directory:
- 1
- Redisplays the first screen of the current file.
- –4
- Goes back 4 windows in the current file and displays a screen
of text.
- p
- Displays the first screen of the previous file.
- 10w
- Sets the screen size to 10 lines.
- /Fred/m
- Finds the first line containing
Fred
searching forward from the current position in the file, and displays
a screen with that line in the middle of the screen.
Localization
pg uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_MESSAGES
- LC_SYNTAX
- NLSPATH
See Localization for more
information.
Exit values
- 0
- Successful completion
- 1
- Failure due to any of the following:
- Unknown command-line option
- Insufficient memory
- Inability to create a temporary file
- Inability to access the terminal
- Missing string after a –p option
Files
pg uses
the following file:
- $TMPDIR/pg*
- Temporary files to allow
backward reading. You can specify a different temporary directory
using the TMPDIR environment variable.
Environment variables
pg uses
the following environment variables:
- COLUMNS
- Contains the
width of the screen in columns.
- LINES
- Contains the
number of lines on the screen.
- TMPDIR
- Contains the
pathname of the directory where temporary files reside.
Portability
X/Open Portability Guide, UNIX System V.
This
implementation does not handle double-byte characters.
The –screen and –+line options
are extensions to the XPG standard.