Linux pg command help and examples(What is, Concept and Definition)

On Unix-like operating systems, the pg command displays the content of text files, one page at a time.


This document covers the Linux version of pg .

Description


pg displays a text file, pausing after each "page" (the height of the terminal screen).After each page, a message is displayed.The user can press the new line key to view the next page or one of the keys described below.


If no file name is provided on the command line, pg is read from standard input.If standard output is not a terminal, pg acts like cat but precedes each file with its name if there is more than one.


If the input comes from a pipeline, pg stores the data in a buffer file while reading to make navigation possible.


Syntax

pg [- number ] [-p string ] [- cefnrs ] [+ line ] [+/ pattern /] [ file ...]

Options






















- number The number of lines per page.Usually this is the number of CRT lines minus one.
-c Clear the screen before a page is displayed, if the terminfo entry for the terminal provides this capability.
-e Do not pause and display "(EOF)" at the end of a file.
-f Do not split long lines.
-n Without this option, commands must end with a newline character.With this option, pg advances once a command letter is entered.
-p string Instead of the normal message ": ", string is displayed.If the string contains "% d ", its first occurrence is replace with the current page number.
-r Do not allow shell escape.
-s Print messages in starred mode, if the terminfo entry for the terminal provides this capability.
+ number Starts at the given line.
+/pattern / Start at the line containing the given basic regular expression pattern .

Commands


The following commands can be entered in the request.Commands preceded by i accept a number as an argument, positive or negative.If this argument begins with + or -, is interpreted relative to the current position in the input file, otherwise relative to the start.




















i Displays the next or indicated page.
i d , ^ D Displays the next half page.If i is provided, it is always interpreted relative to the current position.
i l Shows the next or indicated line.
i f Skip a page forward, i must be a positive number and is always interpreted relative to the current position.
i w , i z Behave as except that i becomes the new page size.
., ^ L Redraws the screen.
$ Advance to the last line of the input file.
i/pattern / Search forward until the first or i occurrence of the basic regular expression pattern is found.The search starts after the current page and stops at the end of the file.No adjustment is made, i must be a positive number.
i? pattern ? , i ^ pattern ^ Search backward until the first or i occurrence of the basic regular expression pattern is found.The search starts before the current page and stops at the beginning of the file.No adjustment is made, i must be a positive number.

The Search commands accept an added letter.If t is given, the line containing the pattern is displayed at the top of the screen, which is the default. m select the center and b the bottom of the screen.The selected position is also used in the following searches.














i n Advance to the next file or i files forward.
i p Reread the previous file or back i files.
s file name Save the current file in the file name .
h Shows a summary of the command.
! command Execute command using the shell.
q , Q Exit.

If the user presses the interrupt or exit key while pg reads from the input file or writes to the terminal, pg will immediately display the message.All others situations these keys will end with pg .


Environment variables


The following environment variables affect the behavior of pg :












COLUMNS Replaces the number of columns provided by the system if configured.
LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES Specific local variables.
LINES Replaces the number of lines provided by the system if configured.
SHELL Used by the command! .
TERM Determines the type of terminal.

Examples

pg myfile.txt

Show the first screen of the text file content myfile.txt , and a message (": ").Pressing the Return key displays the next page, or you can enter any of the commands listed above to navigate the file.

cat -Shows the contents of a file. more -Shows text one screen at a time.

Comments