📄 paste.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>paste</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_1631"> </a>NAME</h4><blockquote>paste - merge corresponding or subsequent lines of files</blockquote><h4><a name = "tag_001_014_1632"> </a>SYNOPSIS</h4><blockquote><pre><code>paste <b>[</b>-s<b>][</b>-d <i>list</i><b>] </b><i>file</i>...</code></pre></blockquote><h4><a name = "tag_001_014_1633"> </a>DESCRIPTION</h4><blockquote>The<i>paste</i>utility will concatenate the corresponding linesof the given input files, and write the resulting lines to standard output.<p>The default operation of<i>paste</i>will concatenate the corresponding lines of the input files.Thenewlinecharacter of every line except theline from the last input file will be replaced with atabcharacter.<p>If an end-of-file condition is detected on one or more inputfiles, but not all input files,<i>paste</i>will behave as thoughempty lines were read from the files on which end-of-file wasdetected, unless the<b>-s</b>option is specified.</blockquote><h4><a name = "tag_001_014_1634"> </a>OPTIONS</h4><blockquote>The<i>paste</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> .<p>The following options are supported:<dl compact><dt><b>-d </b><i>list</i><dd>Unless a backslash character appears in<i>list</i>,each character in<i>list</i>is an element specifying a delimiter character.If a backslash character appears in<i>list</i>,the backslash character and one or more characters followingit are an element specifying a delimiter character as described below.These elements specify one or more delimitersto use, instead of the defaulttab character,to replace thenewlinecharacter ofthe input lines.The elements in<i>list</i>are used circularly; that is,when the list is exhausted the firstelement from the list is reused.When the<b>-s</b>option is specified:<ul><li>The lastnewlinecharacter in a file will not be modified.<li>The delimiter will be resetto the first element of list after each<i>file</i>operand is processed.</ul>When the<b>-s</b>option is not specified:<ul><li>Thenewlinecharacters in the filespecified by the last<i>file</i>operand will not be modified.<li>The delimiterwill be reset to the first element of list each time a line isprocessed from each file.</ul>If a backslash character appears in<i>list</i>,it and the character following it will be used torepresent the following delimiter characters:<dl compact><dt><b>\n</b><dd>Newline character.<dt><b>\t</b><dd>Tab character.<dt><b>\\</b><dd>Backslash character.<dt><b>\0</b><dd>Empty string (not a null character).If\0is immediately followed by the characterx,the characterX,or any character defined by the LC_CTYPE<b>digit</b>keyword (seethe <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b> </a> ),the results are unspecified.</dl><p>If any other characters follow the backslash, the results are unspecified.<br><br><dt><b>-s</b><dd>Concatenate all of the linesof each separate input file in command line order.Thenewlinecharacter of every line except the last line ineach input file will be replaced with thetabcharacter, unless otherwise specified by the<b>-d</b>option.<p></dl></blockquote><h4><a name = "tag_001_014_1635"> </a>OPERANDS</h4><blockquote>The following operand is supported:<dl compact><dt><i>file</i><dd>A pathname of an input file.If "-" is specified for one or more of the<i>file</i>s,the standard input will be used;the standard input will be read one line ata time, circularly, for each instance of "-".Implementations support pasting of at least 12<i>file</i>operands.</dl></blockquote><h4><a name = "tag_001_014_1636"> </a>STDIN</h4><blockquote>The standard input will be used only if one or more<i>file</i>operands is "-".See the INPUT FILES section.</blockquote><h4><a name = "tag_001_014_1637"> </a>INPUT FILES</h4><blockquote>The input files must be text files,except that line lengths will be unlimited.</blockquote><h4><a name = "tag_001_014_1638"> </a>ENVIRONMENT VARIABLES</h4><blockquote>The following environment variables affect the execution of<i>paste</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_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).<dt><i>LC_MESSAGES</i><dd>Determine the locale that should be used to affectthe format and contents of diagnosticmessages written to standard error.<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_1639"> </a>ASYNCHRONOUS EVENTS</h4><blockquote>Default.</blockquote><h4><a name = "tag_001_014_1640"> </a>STDOUT</h4><blockquote>Concatenated lines of input files will be separated by thetabcharacter (or other characters under the control of the<b>-d</b>option) and terminated by anewlinecharacter.</blockquote><h4><a name = "tag_001_014_1641"> </a>STDERR</h4><blockquote>Used only for diagnostic messages.</blockquote><h4><a name = "tag_001_014_1642"> </a>OUTPUT FILES</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1643"> </a>EXTENDED DESCRIPTION</h4><blockquote>None.<br></blockquote><h4><a name = "tag_001_014_1644"> </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_1645"> </a>CONSEQUENCES OF ERRORS</h4><blockquote>If one or more input files cannot be opened when the<b>-s</b>option is not specified, a diagnostic message will be written tostandard error, but no output will be written to standard output.If the<b>-s</b>option is specified, the<i>paste</i>utility will provide the default behaviour described in<a href="utildes.html">Utility Description Defaults</a><xref href=utildes></xref>.</blockquote><h4><a name = "tag_001_014_1646"> </a>APPLICATION USAGE</h4><blockquote>When the escape sequences of the<i>list</i>option-argument are used in a shell script, they must be quoted;otherwise, the shell treats the\as a special character.<p>Portable applications should only use the specificbackslash escaped delimiters presented in this specification.Historical implementations treat\x,wherexis not in this list, asx,but future implementationsare free to expand this list to recognise other common escapessimilar to those accepted by<i><a href="printf.html">printf</a></i>and other standard utilities.<p>Most of the standard utilities work on text files.The<i><a href="cut.html">cut</a></i>utility can be used to turn files with arbitrary line lengthsinto a set of text files containing the same data.The<i>paste</i>utility can be used to create (or recreate) files with arbitraryline lengths.For example, if<b>file</b>contains long lines:<pre><code>cut -b 1-500 -n file > file1cut -b 501- -n file > file2</code></pre>creates<b>file1</b>(a text file) with lines no longer than 500 bytes(plus the newline character) and<b>file2</b>that contains the remainder of the data from<b>file</b>.Note thatfile2will not be a text file if there are lines in file that are longer than 500 +{LINE_MAX}bytes.The original file can be recreated from<b>file1</b>and<b>file2</b>using the command:<pre><code>paste -d "\0" file1 file2 > file</code></pre><p>The commands:<pre><code>paste -d "\0" ...paste -d "" ...</code></pre>are not necessarily equivalent;the latter is not specified by this specification and may result in an error.The construct\0is used to mean "no separator" becausehistorical versions of<i>paste</i>did not follow the syntax guidelines, and the command:<pre><code>paste -d"" ...</code></pre>could not be handled properly by<i><a href="../xsh/getopt.html">getopt()</a></i>.</blockquote><h4><a name = "tag_001_014_1647"> </a>EXAMPLES</h4><blockquote><ol><p><li>Write out a directory in four columns:<pre><code>ls | paste - - - -</code></pre><p><li>Combine pairs of lines from a file into single lines:<pre><code>paste -s -d "\t\n" file</code></pre><p></ol></blockquote><h4><a name = "tag_001_014_1648"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_001_014_1649"> </a>SEE ALSO</h4><blockquote><i><a href="cut.html">cut</a></i>,<i><a href="grep.html">grep</a></i>,<i><a href="pr.html">pr</a></i>.</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 + -