📄 pg.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>pg</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_1726"> </a>NAME</h4><blockquote>pg - file perusal filter for soft-copy terminals (<b><a href="intro.html#tag_001_003_003">LEGACY</a></b>)</blockquote><h4><a name = "tag_001_014_1727"> </a>SYNOPSIS</h4><blockquote><pre><code>pg<b>[</b>-<i>number</i><b>][</b>-cefns<b>][</b>-p <i>string</i><b>][</b>+<i>linenumber</i><b>][</b>+/<i>re</i>/<b>][</b><i>file</i>...<b>]</b></code></pre></blockquote><h4><a name = "tag_001_014_1728"> </a>DESCRIPTION</h4><blockquote>The<i>pg</i>utility is a filter that allows the examination of the named<i>file</i>or files one screenfulat a time on a soft-copy terminal.Each screenful is followed by a prompt.If the user types acarriage-return character,another page is displayed;other possibilities are enumerated in the EXTENDED DESCRIPTIONsection.<p>If the standard output is not a terminal,<i>pg</i>ignores all options and writes the input files to standard output,like the<i><a href="cat.html">cat</a></i>utility,except that a header is written before each file (if there ismore than one).</blockquote><h4><a name = "tag_001_014_1729"> </a>OPTIONS</h4><blockquote>The<i>pg</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> ,except that the<i>-number</i>option takes a multi-digit value and the<i>+linenumber</i>and /<i>re</i>/options take a leading plus sign instead of minus.The following options are supportedwhen standard input is a terminal:<p><dl compact><dt>-<i>number</i><dd>Change window size.The<i>number</i>argument is a positive integer specifying the size (in lines)of the window that<i>pg</i>is to use instead of the default.(The default size is determined by the<i>LINES</i>environment variable.If<i>LINES</i>is unset or null, a terminal-specific default size is used; the<i>TERM</i>environment variable may affect the determination of theterminal-specific default size.The default is typically one less than the number of linesin the terminal window.)<dt><b>-p </b><i>string</i><dd>Use<i>string</i>as the prompt.If the prompt string contains a<b>%d</b>,the first occurrence of<b>%d</b>in the prompt will be replacedby the current page number when the prompt is issued.The default prompt string is ":".<dt><b>-c</b><dd>Home the cursor and clear the screen before displaying each page.This option is ignored if the terminal does not support this.<dt><b>-e</b><dd>Do not pause at the end of each file;see the EXTENDED DESCRIPTION section.<dt><b>-f</b><dd>Inhibit line splitting.Normally,<i>pg</i>splits lines longer than the screen width,but some sequences of charactersin the text being displayed(for example, escape sequences for underlining)generate undesirable results.<dt><b>-n</b><dd>Cause an automatic end-of-command as soon as a command letter is entered.Normally, commands must be terminated by anewlinecharacter.The<b>-n</b>option is not supported on certain block-mode terminals.If<i>pg</i>is being used on such terminal,the<b>-n</b>option will be silently ignoredand the terminatingnewline characterwill be required to complete a command.<dt><b>-s</b><dd>Write all messages and prompts in standoutmode (usually inverse video) if the terminal supports this.<dt>+<i>linenumber</i><dd>Start up at<i>linenumber</i>.<dt>+/<i>re</i>/<dd>Start up at the first line matchingthe basic regular expression<i>re</i>.</dl></blockquote><h4><a name = "tag_001_014_1730"> </a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>file</i><dd>A pathname of a text file to be displayed.If no<i>file</i>is given, or if it is-, the standard input is read.</dl></blockquote><h4><a name = "tag_001_014_1731"> </a>STDIN</h4><blockquote>The standard input is a text file that is used if no<i>file</i>operand is given, or if it is -.</blockquote><h4><a name = "tag_001_014_1732"> </a>INPUT FILES</h4><blockquote>The input file named by the<i>file</i>operand is a text file.</blockquote><h4><a name = "tag_001_014_1733"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>pg</i>:<dl compact><dt><i>COLUMNS</i><dd>Determine the horizontal screen size.If unset or null, use the value of<i>TERM ,</i>the window size, baud rate, or some combination of these,to indicate the terminal type for the screen size calculation.<dt><i>LINES</i><dd>Determine the number of lines to be displayed on the screen.If unset or null, use the value of<i>TERM ,</i>the window size, baud rate, or some combination of these,to indicate the terminal type for the screen size calculation.<dt><i>SHELL</i><dd>Determine the name of the command interpreter executed for a!command.<dt><i>TERM</i><dd>Determine terminal attributes.Optionally attempt to search a system-dependent database,keyed on the value of the<i>TERM</i>environment variable.If no information is available, a terminal incapable ofcursor-addressable movement is assumed.</dl><p>The following environment variables may affect the execution of<i>pg</i>:<dl compact><dt><i>LANG</i><dd>Provide a default value for the internationalisation variablesthat are unset or null.If<i>LANG</i>is unset or null, the corresponding value from theimplementation-dependent default locale will be used.If any of the internationalisation variables contains an invalid setting, theutility will behave as if none of the variables had been defined.<dt><i>LC_ALL</i><dd>If set to a non-empty string value,override the values of all the other internationalisation variables.<dt><i>LC_COLLATE</i><dd>Determine the locale for thebehaviour of ranges, equivalence classesand multi-character collating elementswithin regular expressions.<dt><i>LC_CTYPE</i><dd>Determine thelocale for the interpretation of sequences of bytes of text data ascharacters (for example, single- as opposed to multi-byte charactersin arguments and input files) andthe behaviour of character classes within regular expressions.<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error,and informative messages written to standard output.<dt><i>NLSPATH</i><dd>Determine the location of message cataloguesfor the processing of<i>LC_MESSAGES .</i></dl></blockquote><h4><a name = "tag_001_014_1734"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>During the writing of characters to the standard output,<i>pg</i>catches SIGINT and SIGQUIT, returning the user to the prompt.When waiting at the prompt,<i>pg</i>takes the default action on SIGINT and SIGQUIT.The default actions are taken for all other signals.</blockquote><h4><a name = "tag_001_014_1735"> </a>STDOUT</h4><blockquote>The standard output is a display of the input files,with prompts interspersed.When standard output is not associated with a terminal,it consists of the contents of the input files, separatedby the following lines, if there is more than one input file:<p><code><tt>"::::::::::::::\n%s\n::::::::::::::\n"</tt>, <<i>pathname</i>></code></blockquote><h4><a name = "tag_001_014_1736"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_1737"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1738"> </a>EXTENDED DESCRIPTION</h4><blockquote>The responses that can be typed when<i>pg</i>pauses can be dividedinto three categories: those causing further perusal, those thatsearch and those that modify the perusal environment.<p>Commands that cause further perusal normally take a precedingaddress; an optionally signed number indicating the point fromwhich further text should be displayed.This address isinterpreted in either pages or lines depending on the command.A signed address specifies a point relative to the current page orline, and an unsigned address specifies an address relative to thebeginning of the file.Each command has a default address that isused if none is provided.<p>The perusal commands and their defaults are as follows:<dl compact><dt>(+1)<newline> or <space><dd>Display one page.The address is specified in number of pages.<dt>(+1)<b>l</b><dd>With a relative address,simulate scrolling the screen, forward or backward, bythe number of lines specified.With an absolute address,print a screenfulbeginning at the specified line.<dt>(+1)<b>d </b>or <control>-D<dd>Simulate scrolling half a screen forward or backward.</dl><p>The following perusal commands take no address:<dl compact><dt><b>. </b>or <control>-L<dd>Redisplay the current page of text.<dt><b>$</b><dd>Display the last windowful in the file.</dl><p>The following commands are available for searching for text patternsin the text.Basic regular expression syntax is used in patterns.The<i>re</i>smust always be terminated by anewline character,even if the<b>-n</b>option is specified.<dl compact><dt><i>i</i><b>/</b><i>re</i><b>/</b><dd>Search forwards for the<i>i</i>thoccurrence of<i>re</i>(default<i>i</i>=1).Searching begins immediately after the current page and continues to theend of the current file, without wrap-around.<dt><i>i</i>^<i>re</i>^<dd><dt><i>i</i>?<i>re</i>?<dd>Search backwards for the<i>i</i>thoccurrence of<i>re</i>(default<i>i</i>=1).Searching begins immediately before the current pageand continues to the beginning of the current file, withoutwrap-around.</dl><p>After searching,<i>pg</i>will normally display the line found at the top of the screen.This can be modified by appending<b>m</b>or<b>b</b>to the searchcommand to leave the line found in the middle or at the bottom ofthe window from now on.The suffix<b>t</b>can be used to restore the original situation.<p>If the standard output is not a terminal device,<i>pg</i>always exits whenit reaches end-of-file on the last file in its argument list.Otherwise, for allfiles but the last,<i>pg</i>prompts with an indicationthat it has reached the end-of-file, along with the name ofthe next file;when<b>-e</b>is used, the end-of-file prompt is bypassedand the prompt indicates the name of the next file.For the last file specified, or for thestandard input if no file is specified,<i>pg</i>prompts indicating end-of-file (if<b>-e</b>is not used), and accepts additional commands.If the next command specifies forward scrolling,<i>pg</i>exits.If the<b>-e</b>option is specified,<i>pg</i>exits immediately after writing the last line of the last file.<br><p>The user of<i>pg</i>can modify the environment of perusal with thefollowing commands:<dl compact><dt><i>i</i><b>n</b><dd>Begin perusing the<i>i</i>thnext file in the command line.The<i>i</i>is an unsigned number; default value is 1.<dt><i>i</i><b>p</b><dd>Begin perusing the<i>i</i>thprevious file in the command line.The<i>i</i>is an unsigned number; default is 1.<dt><i>i</i><b>w</b><dd>Display another window of text.If<i>i</i>is present, set the window size to<i>i</i>.<dt><b>s</b><i> filename</i><dd>Save the input in the file named<i>filename</i>.Only the current file being perused is saved.Theblank-character-separationbetween the<b>s</b>and<i>filename</i>is optional.This command must always be terminated by anewline character,even if the<b>-n</b>option is specified.<dt><b>h</b><dd>Help by displaying an abbreviated summary of available commands.<dt><b>q </b>or <b>Q</b><dd>Quit<i>pg</i>.<dt><b>!</b><i>command</i><dd>Pass the argument<i>command</i>to the command interpreter, whose name istaken from the<i>SHELL</i>environment variable.If<i>SHELL</i>is unset or null,<i><a href="sh.html">sh</a></i>is used as the defaultcommand interpreter.This command must always be terminated by anewline character,even if the<b>-n</b>option is specified.</dl><p>At any time when output is being sent to the terminal, receipt of aquit or interrupt signal causes<i>pg</i>to stop sending output and to 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, due to the factthat any characters waiting in the terminal's output queue are flushedwhen the signal occurs.</blockquote><h4><a name = "tag_001_014_1739"> </a>EXIT STATUS</h4><blockquote>The following exit values are returned:<dl compact><dt>0<dd>Successful completion.<dt>>0<dd>An error occurred.</dl></blockquote><h4><a name = "tag_001_014_1740"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1741"> </a>APPLICATION USAGE</h4><blockquote>This utility is different from previous paginatorsin that it allows the user to back upand review something that has already passed.The method for doing this is explained in theEXTENDED DESCRIPTION section.<p>While waiting for terminal input,<i>pg</i>responds toSIGINTandSIGQUITsignals by terminating execution.Between prompts, however, these signals interrupt<i>pg</i>'scurrent task and place the user in prompt mode.These signals should be used with caution when input is being read froma pipe, since an interrupt is likely to terminate the othercommands in the pipeline.<p>Use the<b>$</b>command with caution when the input is a pipe.<p>If terminal tabs are not set every eight column positions,undesirable results may occur.<p>When<i>pg</i>is used as a filter with another command that changes the terminalI/O options, terminal settings might not be restored correctly.<p>Applications should migrate to the<i><a href="more.html">more</a></i>utility.</blockquote><h4><a name = "tag_001_014_1742"> </a>EXAMPLES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1743"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1744"> </a>SEE ALSO</h4><blockquote><i><a href="more.html">more</a></i>,the <b>XBD</b> specification, <a href="../xbd/re.html#tag_007_003"><b>Basic Regular Expressions</b> </a> ,the <b>XBD</b> specification, <a href="../xbd/termios.html"><b>General Terminal Interface</b> </a> .</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -