pr.html
来自「IEEE 1003.1-2003, Single Unix Specificat」· HTML 代码 · 共 460 行 · 第 1/2 页
HTML
460 行
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments and input files) and which characters are defined as printable (character class<b>print</b>). Non-printable characters are still written to standard output, but are not counted for the purpose for column-widthand line-length calculations.</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standarderror.</dd><dt><i>LC_TIME</i></dt><dd>Determine the format of the date and time for use in writing header lines.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><i>TZ</i></dt><dd>Determine the timezone used to calculate date and time strings written in header lines. If <i>TZ</i> is unset or null, anunspecified default timezone shall be used.</dd></dl></blockquote><h4><a name="tag_04_101_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>If <i>pr</i> receives an interrupt while writing to a terminal, it shall flush all accumulated error messages to the screenbefore terminating.</p></blockquote><h4><a name="tag_04_101_10"></a>STDOUT</h4><blockquote><p>The <i>pr</i> utility output shall be a paginated version of the original file (or files). This pagination shall be accomplishedusing either <form-feed>s or a sequence of <newline>s, as controlled by the <b>-F</b> <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or <b>-f</b><img src="../images/opt-end.gif" alt="[Option End]" border="0"> option. Page headers shall be generated unless the <b>-t</b> optionis specified. The page headers shall be of the form:</p><pre><tt>"\n\n%s %s Page %d\n\n\n", <</tt><i>output of date</i><tt>>, <</tt><i>file</i><tt>>, <</tt><i>page number</i><tt>></tt></pre><p>In the POSIX locale, the <<i>output of date</i>> field, representing the date and time of last modification ofthe input file (or the current date and time if the input file is standard input), shall be equivalent to the output of thefollowing command as it would appear if executed at the given time:</p><pre><tt>date "+%b %e %H:%M %Y"</tt></pre><p>without the trailing <newline>, if the page being written is from standard input. If the page being written is not fromstandard input, in the POSIX locale, the same format shall be used, but the time used shall be the modification time of the filecorresponding to <i>file</i> instead of the current time. When the <i>LC_TIME</i> locale category is not set to the POSIX locale, adifferent format and order of presentation of this field may be used.</p><p>If the standard input is used instead of a <i>file</i> operand, the <<i>file</i>> field shall be replaced by a nullstring.</p><p>If the <b>-h</b> option is specified, the <<i>file</i>> field shall be replaced by the <i>header</i> argument.</p></blockquote><h4><a name="tag_04_101_11"></a>STDERR</h4><blockquote><p>The standard error shall be used for diagnostic messages and for alerting the terminal when <b>-p</b> is specified.</p></blockquote><h4><a name="tag_04_101_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_101_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_101_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>Successful completion.</dd><dt>>0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_101_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_101_16"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_101_17"></a>EXAMPLES</h4><blockquote><ol><li><p>Print a numbered list of all files in the current directory:</p><pre><tt>ls -a | pr -n -h "Files in $(pwd)."</tt></pre></li><li><p>Print <b>file1</b> and <b>file2</b> as a double-spaced, three-column listing headed by "file list'':</p><pre><tt>pr -3d -h "file list" file1 file2</tt></pre></li><li><p>Write <b>file1</b> on <b>file2</b>, expanding tabs to columns 10, 19, 28, ...:</p><pre><tt>pr -e9 -t <file1 >file2</tt></pre></li></ol></blockquote><h4><a name="tag_04_101_18"></a>RATIONALE</h4><blockquote><p>This utility is one of those that does not follow the Utility Syntax Guidelines because of its historical origins. The standarddevelopers could have added new options that obeyed the guidelines (and marked the old options obsolescent) or devised an entirelynew utility; there are examples of both actions in this volume of IEEE Std 1003.1-2001. Because of its widespread use byhistorical applications, the standard developers decided to exempt this version of <i>pr</i> from many of the guidelines.</p><p>Implementations are required to accept option-arguments to the <b>-h</b>, <b>-l</b>, <b>-o</b>, and <b>-w</b> options whetherpresented as part of the same argument or as a separate argument to <i>pr</i>, as suggested by the Utility Syntax Guidelines. The<b>-n</b> and <b>-s</b> options, however, are specified as in historical practice because they are frequently specified withouttheir optional arguments. If a <blank> were allowed before the option-argument in these cases, a <i>file</i> operand couldmistakenly be interpreted as an option-argument in historical applications.</p><p>The text about the minimum number of lines in multi-column output was included to ensure that a best effort is made in balancingthe length of the columns. There are known historical implementations in which, for example, 60-line files are listed by <i>pr</i>-2 as one column of 56 lines and a second of 4. Although this is not a problem when a full page with headers and trailers isproduced, it would be relatively useless when used with <b>-t</b>.</p><p>Historical implementations of the <i>pr</i> utility have differed in the action taken for the <b>-f</b> option. BSD uses it asdescribed here for the <b>-F</b> option; System V uses it to change trailing <newline>s on each page to a <form-feed>and, if standard output is a TTY device, sends an <alert> to standard error and reads a line from <b>/dev/tty</b> before thefirst page. There were strong arguments from both sides of this issue concerning historical practice and as a result the <b>-F</b>option was added. XSI-conformant systems support the System V historical actions for the <b>-f</b> option.</p><p>The <<i>output of date</i>> field in the <b>-l</b> format is specified only for the POSIX locale. As noted, theformat can be different in other locales. No mechanism for defining this is present in this volume ofIEEE Std 1003.1-2001, as the appropriate vehicle is a message catalog; that is, the format should be specified as a"message".</p></blockquote><h4><a name="tag_04_101_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_101_20"></a>SEE ALSO</h4><blockquote><p><a href="expand.html"><i>expand</i></a> , <a href="lp.html"><i>lp</i></a></p></blockquote><h4><a name="tag_04_101_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_101_22"></a>Issue 6</h4><blockquote><p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p><ul><li><p>The <b>-p</b> option is added.</p></li></ul><p>The normative text is reworded to avoid use of the term "must" for application requirements.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?