Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cat(1)

grep(1)

/egrep(1)

/fgrep(1)

more(1)

/page(1)

terminfo(4)

pg(1)  —  Commands

OSF

NAME

pg − Formats files for a tty 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. 

FLAGS

-cMoves the cursor to the home position and clears the screen before each page.  This flag is ignored if clear_screen is not defined for your tty type in the terminfo file. 

-eDoes not pause at the end of each file.  However, pg still pauses at the beginning of each file. 

-fDoes not split lines.  Normally, pg splits (wraps) lines longer than the screen width. 

-nStops processing when a pg command letter is entered.  Normally, commands must end with a newline character. 

-p stringUses 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. 

-sHighlights all messages and prompts. 

+line_number
Starts at line_number. 

-numberSpecifies the number of lines in the window. 

+/pattern/
Starts at the first line that contains pattern. 

DESCRIPTION

If you specify file as a - (dash) or run pg without arguments, pg reads standard input.  To determine tty attributes, pg looks up the tty 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 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 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 tty, 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 tty tabs are not set for every eight positions, unpredictable results can occur. 

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:

numberDisplays page number number. 

+number
Displays the page number pages after the current page. 

-numberDisplays the page number pages before the current page. 

lScrolls the display one line forward. 

numberlDisplays a screen with the specified line number at the top. 

+numberl
Scrolls the display number lines forward. 

-numberlScrolls the display number lines backward. 

dScrolls half a screen forward.  Pressing <Ctrl-d> (and <Return> if you haven’t specified -n) has the same effect. 

-dScrolls half a screen backward.  Pressing - and then <Ctrl-d> (and <Return> if you haven’t specified -n) has the same effect. 

+numberf
Skips number screens forward. 

-numberfSkips number screens backward. 

<Ctrl-l>
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 flag is used.  In an expression such as [a-z], the dash means through according to the current collating sequence.  See OSF/1 User’s Guide for more information on collating sequences.  The collating sequence is determined by the value of the LC_COLLATE environment variable. 

[number]/pattern/
Searches for the number’th occurrence 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. 

number?pattern?
or

number^pattern^
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 terminal, 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 displaying the line with the pattern to the top of the screen. 

Environment Subcommands

You can change the pg environment with the following subcommands:

[number]n
Begins examining the number’th next file in the command line.  The default number is 1. 

[number]p
Begins examining the number’th previous file on the command line.  The default number is 1. 

[number]w
Sets the window size to number.  If number is not present, displays another window of text. 

[number]lz
Same as w. 

s fileSaves 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 flag. 

hDisplays an abbreviated summary of available subcommands. 

q or QQuits pg. 

!command
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 flag is used. 

EXAMPLES

To look at the contents of file file1 one page at a time, enter:

pg file1

FILES

/usr/share/lib/terminfo/?/∗
Terminal capability database.

/tmp/pg∗Temporary file used when input is from a pipe. 

RELATED INFORMATION

Commands:  cat(1), grep(1)/egrep(1)/fgrep(1), more(1)/page(1). 

Files:  terminfo(4). 

OSF/1 User’s Guide. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026