⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 paste.html

📁 posix标准英文,html格式
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>paste</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="paste"></a> <a name="tag_04_97"></a><!-- paste --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_97_01"></a>NAME</h4><blockquote>paste - merge corresponding or subsequent lines of files</blockquote><h4><a name="tag_04_97_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>paste</tt> <b>[</b><tt>-s</tt><b>][</b><tt>-d</tt> <i>list</i><b>]</b> <i>file</i><tt>...</tt></code></p></blockquote><h4><a name="tag_04_97_03"></a>DESCRIPTION</h4><blockquote><p>The <i>paste</i> utility shall concatenate the corresponding lines of the given input files, and write the resulting lines tostandard output.</p><p>The default operation of <i>paste</i> shall concatenate the corresponding lines of the input files. The &lt;newline&gt; of everyline except the line from the last input file shall be replaced with a &lt;tab&gt;.</p><p>If an end-of-file condition is detected on one or more input files, but not all input files, <i>paste</i> shall behave as thoughempty lines were read from the files on which end-of-file was detected, unless the <b>-s</b> option is specified.</p></blockquote><h4><a name="tag_04_97_04"></a>OPTIONS</h4><blockquote><p>The <i>paste</i> utility shall conform to the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following options shall be supported:</p><dl compact><dt><b>-d&nbsp;</b> <i>list</i></dt><dd>Unless a backslash character appears in <i>list</i>, each character in <i>list</i> is an element specifying a delimitercharacter. If a backslash character appears in <i>list</i>, the backslash character and one or more characters following it are anelement specifying a delimiter character as described below. These elements specify one or more delimiters to use, instead of thedefault &lt;tab&gt;, to replace the &lt;newline&gt; of the input lines. The elements in <i>list</i> shall be used circularly; thatis, when the list is exhausted the first element from the list is reused. When the <b>-s</b> option is specified: <ul><li><p>The last &lt;newline&gt; in a file shall not be modified.</p></li><li><p>The delimiter shall be reset to the first element of <i>list</i> after each <i>file</i> operand is processed.</p></li></ul><p>When the <b>-s</b> option is not specified:</p><ul><li><p>The &lt;newline&gt;s in the file specified by the last <i>file</i> operand shall not be modified.</p></li><li><p>The delimiter shall be reset to the first element of list each time a line is processed from each file.</p></li></ul><p>If a backslash character appears in <i>list</i>, it and the character following it shall be used to represent the followingdelimiter characters:</p><dl compact><dt><tt>\n</tt></dt><dd>&lt;newline&gt;.</dd><dt><tt>\t</tt></dt><dd>&lt;tab&gt;.</dd><dt><tt>\\</tt></dt><dd>Backslash character.</dd><dt><tt>\0</tt></dt><dd>Empty string (not a null character). If <tt>'\0'</tt> is immediately followed by the character <tt>'x'</tt>, the character<tt>'X'</tt>, or any character defined by the <i>LC_CTYPE</i> <b>digit</b> keyword (see the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap07.html">Chapter 7, Locale</a>), the results are unspecified.</dd></dl><p>If any other characters follow the backslash, the results are unspecified.</p></dd><dt><b>-s</b></dt><dd>Concatenate all of the lines of each separate input file in command line order. The &lt;newline&gt; of every line except thelast line in each input file shall be replaced with the &lt;tab&gt;, unless otherwise specified by the <b>-d</b> option.</dd></dl></blockquote><h4><a name="tag_04_97_05"></a>OPERANDS</h4><blockquote><p>The following operand shall be supported:</p><dl compact><dt><i>file</i></dt><dd>A pathname of an input file. If <tt>'-'</tt> is specified for one or more of the <i>file</i>s, the standard input shall beused; the standard input shall be read one line at a time, circularly, for each instance of <tt>'-'</tt>. Implementations shallsupport pasting of at least 12 <i>file</i> operands.</dd></dl></blockquote><h4><a name="tag_04_97_06"></a>STDIN</h4><blockquote><p>The standard input shall be used only if one or more <i>file</i> operands is <tt>'-'</tt>. See the INPUT FILES section.</p></blockquote><h4><a name="tag_04_97_07"></a>INPUT FILES</h4><blockquote><p>The input files shall be text files, except that line lengths shall be unlimited.</p></blockquote><h4><a name="tag_04_97_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>paste</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_CTYPE</i></dt><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).</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>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></dl></blockquote><h4><a name="tag_04_97_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_97_10"></a>STDOUT</h4><blockquote><p>Concatenated lines of input files shall be separated by the &lt;tab&gt; (or other characters under the control of the <b>-d</b>option) and terminated by a &lt;newline&gt;.</p></blockquote><h4><a name="tag_04_97_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_97_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_97_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_97_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt>&nbsp;0</dt><dd>Successful completion.</dd><dt>&gt;0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_97_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>If one or more input files cannot be opened when the <b>-s</b> option is not specified, a diagnostic message shall be written tostandard error, but no output is written to standard output. If the <b>-s</b> option is specified, the <i>paste</i> utility shallprovide the default behavior described in <a href="xcu_chap01.html#tag_01_11"><i>Utility Description Defaults</i></a>.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_97_16"></a>APPLICATION USAGE</h4><blockquote><p>When the escape sequences of the <i>list</i> option-argument are used in a shell script, they must be quoted; otherwise, theshell treats the <tt>'\'</tt> as a special character.</p><p>Conforming applications should only use the specific backslash escaped delimiters presented in this volume ofIEEE&nbsp;Std&nbsp;1003.1-2001. Historical implementations treat <tt>'\x'</tt>, where <tt>'x'</tt> is not in this list, as<tt>'x'</tt>, but future implementations are free to expand this list to recognize other common escapes similar to those acceptedby <a href="../utilities/printf.html"><i>printf</i></a> and other standard utilities.</p><p>Most of the standard utilities work on text files. The <a href="../utilities/cut.html"><i>cut</i></a> utility can be used toturn files with arbitrary line lengths into a set of text files containing the same data. The <i>paste</i> utility can be used tocreate (or recreate) files with arbitrary line lengths. For example, if <i>file</i> contains long lines:</p><pre><tt>cut -b 1-500 -n file &gt; file1cut -b 501- -n file &gt; file2</tt></pre><p>creates <b>file1</b> (a text file) with lines no longer than 500 bytes (plus the &lt;newline&gt;) and <b>file2</b> that containsthe remainder of the data from <i>file</i>. Note that <b>file2</b> is not a text file if there are lines in <i>file</i> that arelonger than 500 + {LINE_MAX} bytes. The original file can be recreated from <b>file1</b> and <b>file2</b> using the command:</p><pre><tt>paste -d "\0" file1 file2 &gt; file</tt></pre><p>The commands:</p><pre><tt>paste -d "\0" ...paste -d "" ...</tt></pre><p>are not necessarily equivalent; the latter is not specified by this volume of IEEE&nbsp;Std&nbsp;1003.1-2001 and may result inan error. The construct <tt>'\0'</tt> is used to mean &quot;no separator&quot; because historical versions of <i>paste</i> did not followthe syntax guidelines, and the command:</p><pre><tt>paste -d"" ...</tt></pre><p>could not be handled properly by <a href="../functions/getopt.html"><i>getopt</i>()</a>.</p></blockquote><h4><a name="tag_04_97_17"></a>EXAMPLES</h4><blockquote><ol><li><p>Write out a directory in four columns:</p><pre><tt>ls | paste - - - -</tt></pre></li><li><p>Combine pairs of lines from a file into single lines:</p><pre><tt>paste -s -d "\t\n" file</tt></pre></li></ol></blockquote><h4><a name="tag_04_97_18"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_97_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_97_20"></a>SEE ALSO</h4><blockquote><p><a href="xcu_chap01.html#tag_01_11"><i>Utility Description Defaults</i></a>, <a href="cut.html"><i>cut</i></a>, <a href="grep.html"><i>grep</i></a>, <a href="pr.html"><i>pr</i></a></p></blockquote><h4><a name="tag_04_97_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_97_22"></a>Issue 6</h4><blockquote><p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -