isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

paste.html (14712B)


      1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved -->
      2 <!DOCTYPE HTML>
      3 <html lang="en">
      4 <head>
      5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0">
      6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 -->
      8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved -->
      9 <title>paste</title>
     10 </head>
     11 <body bgcolor="white">
     12 <div class="NAVHEADER">
     13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
     14 <tr class="nav">
     15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/od.html" accesskey="P">&lt;&lt;&lt;
     16 Previous</a></td>
     17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
     18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/patch.html" accesskey="N">Next
     19 &gt;&gt;&gt;</a></td>
     20 </tr>
     21 </table>
     22 <hr align="left" width="100%"></div>
     23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3">
     24 <center><font size="2">The Open Group Base Specifications Issue 8<br>
     25 IEEE Std 1003.1-2024<br>
     26 Copyright © 2001-2024 The IEEE and The Open Group</font></center>
     27 <hr size="2" noshade>
     28 <a name="top" id="top"></a> <a name="paste" id="paste"></a> <a name="tag_20_91" id="tag_20_91"></a><!-- paste -->
     29 <h4 class="mansect"><a name="tag_20_91_01" id="tag_20_91_01"></a>NAME</h4>
     30 <blockquote>paste — merge corresponding or subsequent lines of files</blockquote>
     31 <h4 class="mansect"><a name="tag_20_91_02" id="tag_20_91_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <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>
     34 </blockquote>
     35 <h4 class="mansect"><a name="tag_20_91_03" id="tag_20_91_03"></a>DESCRIPTION</h4>
     36 <blockquote>
     37 <p>The <i>paste</i> utility shall concatenate the corresponding lines of the given input files, and write the resulting lines to
     38 standard output.</p>
     39 <p>The default operation of <i>paste</i> shall concatenate the corresponding lines of the input files. The &lt;newline&gt; of every
     40 line except the line from the last input file shall be replaced with a &lt;tab&gt;.</p>
     41 <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 though
     42 empty lines were read from the files on which end-of-file was detected, unless the <b>-s</b> option is specified.</p>
     43 </blockquote>
     44 <h4 class="mansect"><a name="tag_20_91_04" id="tag_20_91_04"></a>OPTIONS</h4>
     45 <blockquote>
     46 <p>The <i>paste</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     47 Guidelines</i></a> .</p>
     48 <p>The following options shall be supported:</p>
     49 <dl compact>
     50 <dd></dd>
     51 <dt><b>-d&nbsp;</b><i>list</i></dt>
     52 <dd>Unless a &lt;backslash&gt; character appears in <i>list</i>, each character in <i>list</i> is an element specifying a delimiter
     53 character. If a &lt;backslash&gt; character appears in <i>list</i>, the &lt;backslash&gt; character and one or more characters
     54 following it are an element specifying a delimiter character as described below. These elements specify one or more delimiters to
     55 use, instead of the default &lt;tab&gt;, to replace the &lt;newline&gt; of the input lines. The elements in <i>list</i> shall be
     56 used circularly; that is, when the list is exhausted the first element from the list is reused. When the <b>-s</b> option is
     57 specified:
     58 <ul>
     59 <li>
     60 <p>The last &lt;newline&gt; in a file shall not be modified.</p>
     61 </li>
     62 <li>
     63 <p>The delimiter shall be reset to the first element of <i>list</i> after each <i>file</i> operand is processed.</p>
     64 </li>
     65 </ul>
     66 <p>When the <b>-s</b> option is not specified:</p>
     67 <ul>
     68 <li>
     69 <p>The &lt;newline&gt; characters in the file specified by the last <i>file</i> operand shall not be modified.</p>
     70 </li>
     71 <li>
     72 <p>The delimiter shall be reset to the first element of list each time a line is processed from each file.</p>
     73 </li>
     74 </ul>
     75 <p>If a &lt;backslash&gt; character appears in <i>list</i>, it and the character following it shall be used to represent the
     76 following delimiter characters:</p>
     77 <dl compact>
     78 <dd></dd>
     79 <dt><tt>\n</tt></dt>
     80 <dd>&lt;newline&gt;.</dd>
     81 <dt><tt>\t</tt></dt>
     82 <dd>&lt;tab&gt;.</dd>
     83 <dt><tt>\\</tt></dt>
     84 <dd>&lt;backslash&gt; character.</dd>
     85 <dt><tt>\0</tt></dt>
     86 <dd>Empty string (not a null character). If <tt>'\0'</tt> is immediately followed by the character <tt>'x'</tt>, the character
     87 <tt>'X'</tt>, or any character defined by the <i>LC_CTYPE</i> <b>digit</b> keyword (see XBD <a href=
     88 "../basedefs/V1_chap07.html#tag_07"><i>7. Locale</i></a> ), the results are unspecified.</dd>
     89 </dl>
     90 <p>If any other characters follow the &lt;backslash&gt;, the results are unspecified.</p>
     91 </dd>
     92 <dt><b>-s</b></dt>
     93 <dd>Concatenate all of the lines from each input file into one line of output per file, in command line order. The &lt;newline&gt;
     94 of every line except the last line in each input file shall be replaced with a &lt;tab&gt;, unless otherwise specified by the
     95 <b>-d</b> option. If an input file is empty, the output line corresponding to that file shall consist of only a &lt;newline&gt;
     96 character.</dd>
     97 </dl>
     98 </blockquote>
     99 <h4 class="mansect"><a name="tag_20_91_05" id="tag_20_91_05"></a>OPERANDS</h4>
    100 <blockquote>
    101 <p>The following operand shall be supported:</p>
    102 <dl compact>
    103 <dd></dd>
    104 <dt><i>file</i></dt>
    105 <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 be
    106 used; the standard input shall be read one line at a time, circularly, for each instance of <tt>'-'</tt>. Implementations shall
    107 support pasting of at least 12 <i>file</i> operands.</dd>
    108 </dl>
    109 </blockquote>
    110 <h4 class="mansect"><a name="tag_20_91_06" id="tag_20_91_06"></a>STDIN</h4>
    111 <blockquote>
    112 <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>
    113 </blockquote>
    114 <h4 class="mansect"><a name="tag_20_91_07" id="tag_20_91_07"></a>INPUT FILES</h4>
    115 <blockquote>
    116 <p>The input files shall be text files, except that line lengths shall be unlimited.</p>
    117 </blockquote>
    118 <h4 class="mansect"><a name="tag_20_91_08" id="tag_20_91_08"></a>ENVIRONMENT VARIABLES</h4>
    119 <blockquote>
    120 <p>The following environment variables shall affect the execution of <i>paste</i>:</p>
    121 <dl compact>
    122 <dd></dd>
    123 <dt><i>LANG</i></dt>
    124 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    125 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> the precedence of internationalization
    126 variables used to determine the values of locale categories.)</dd>
    127 <dt><i>LC_ALL</i></dt>
    128 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    129 <dt><i>LC_CTYPE</i></dt>
    130 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    131 opposed to multi-byte characters in arguments and input files).</dd>
    132 <dt><i>LC_MESSAGES</i></dt>
    133 <dd><br>
    134 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    135 <dt><i>NLSPATH</i></dt>
    136 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    137 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    138 "0"></dd>
    139 </dl>
    140 </blockquote>
    141 <h4 class="mansect"><a name="tag_20_91_09" id="tag_20_91_09"></a>ASYNCHRONOUS EVENTS</h4>
    142 <blockquote>
    143 <p>Default.</p>
    144 </blockquote>
    145 <h4 class="mansect"><a name="tag_20_91_10" id="tag_20_91_10"></a>STDOUT</h4>
    146 <blockquote>
    147 <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>
    148 option) and terminated by a &lt;newline&gt;.</p>
    149 </blockquote>
    150 <h4 class="mansect"><a name="tag_20_91_11" id="tag_20_91_11"></a>STDERR</h4>
    151 <blockquote>
    152 <p>The standard error shall be used only for diagnostic messages.</p>
    153 </blockquote>
    154 <h4 class="mansect"><a name="tag_20_91_12" id="tag_20_91_12"></a>OUTPUT FILES</h4>
    155 <blockquote>
    156 <p>None.</p>
    157 </blockquote>
    158 <h4 class="mansect"><a name="tag_20_91_13" id="tag_20_91_13"></a>EXTENDED DESCRIPTION</h4>
    159 <blockquote>
    160 <p>None.</p>
    161 </blockquote>
    162 <h4 class="mansect"><a name="tag_20_91_14" id="tag_20_91_14"></a>EXIT STATUS</h4>
    163 <blockquote>
    164 <p>The following exit values shall be returned:</p>
    165 <dl compact>
    166 <dd></dd>
    167 <dt>&nbsp;0</dt>
    168 <dd>Successful completion.</dd>
    169 <dt>&gt;0</dt>
    170 <dd>An error occurred.</dd>
    171 </dl>
    172 </blockquote>
    173 <h4 class="mansect"><a name="tag_20_91_15" id="tag_20_91_15"></a>CONSEQUENCES OF ERRORS</h4>
    174 <blockquote>
    175 <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 to
    176 standard error, but no output is written to standard output. If the <b>-s</b> option is specified, the <i>paste</i> utility shall
    177 provide the default behavior described in <a href="../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description
    178 Defaults</i></a> .</p>
    179 </blockquote>
    180 <hr>
    181 <div class="box"><em>The following sections are informative.</em></div>
    182 <h4 class="mansect"><a name="tag_20_91_16" id="tag_20_91_16"></a>APPLICATION USAGE</h4>
    183 <blockquote>
    184 <p>When the escape sequences of the <i>list</i> option-argument are used in a shell script, they must be quoted; otherwise, the
    185 shell treats the &lt;backslash&gt; as a special character.</p>
    186 <p>Conforming applications should only use the specific &lt;backslash&gt;-escaped delimiters presented in this volume of
    187 POSIX.1-2024. Historical implementations treat <tt>'\x'</tt>, where <tt>'x'</tt> is not in this list, as <tt>'x'</tt>, but future
    188 implementations are free to expand this list to recognize other common escapes similar to those accepted by <a href=
    189 "../utilities/printf.html"><i>printf</i></a> and other standard utilities.</p>
    190 <p>Most of the standard utilities work on text files. The <a href="../utilities/cut.html"><i>cut</i></a> utility can be used to
    191 turn files with arbitrary line lengths into a set of text files containing the same data. The <i>paste</i> utility can be used to
    192 create (or recreate) files with arbitrary line lengths. For example, if <i>file</i> contains long lines:</p>
    193 <pre>
    194 <tt>cut -b 1-500 -n file &gt; file1
    195 cut -b 501- -n file &gt; file2
    196 </tt></pre>
    197 <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 contains
    198 the 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 are
    199 longer than 500 + {LINE_MAX} bytes. The original file can be recreated from <b>file1</b> and <b>file2</b> using the command:</p>
    200 <pre>
    201 <tt>paste -d "\0" file1 file2 &gt; file
    202 </tt></pre>
    203 <p>The commands:</p>
    204 <pre>
    205 <tt>paste -d "\0" ...
    206 paste -d "" ...
    207 </tt></pre>
    208 <p>are not necessarily equivalent; the latter is not specified by this volume of POSIX.1-2024 and may result in an error. The
    209 construct <tt>'\0'</tt> is used to mean &quot;no separator&quot; because historical versions of <i>paste</i> did not follow the syntax
    210 guidelines, and the command:</p>
    211 <pre>
    212 <tt>paste -d"" ...
    213 </tt></pre>
    214 <p>could not be handled properly by <a href="../functions/getopt.html"><i>getopt</i>()</a>.</p>
    215 </blockquote>
    216 <h4 class="mansect"><a name="tag_20_91_17" id="tag_20_91_17"></a>EXAMPLES</h4>
    217 <blockquote>
    218 <ol>
    219 <li>
    220 <p>Write out a directory in four columns:</p>
    221 <pre>
    222 <tt>ls | paste - - - -
    223 </tt></pre></li>
    224 <li>
    225 <p>Combine pairs of lines from a file into single lines:</p>
    226 <pre>
    227 <tt>paste -s -d "\t\n" file
    228 </tt></pre></li>
    229 </ol>
    230 </blockquote>
    231 <h4 class="mansect"><a name="tag_20_91_18" id="tag_20_91_18"></a>RATIONALE</h4>
    232 <blockquote>
    233 <p>None.</p>
    234 </blockquote>
    235 <h4 class="mansect"><a name="tag_20_91_19" id="tag_20_91_19"></a>FUTURE DIRECTIONS</h4>
    236 <blockquote>
    237 <p>None.</p>
    238 </blockquote>
    239 <h4 class="mansect"><a name="tag_20_91_20" id="tag_20_91_20"></a>SEE ALSO</h4>
    240 <blockquote>
    241 <p><a href="../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> , <a href=
    242 "../utilities/cut.html#"><i>cut</i></a> , <a href="../utilities/grep.html#"><i>grep</i></a> , <a href=
    243 "../utilities/pr.html#"><i>pr</i></a></p>
    244 <p>XBD <a href="../basedefs/V1_chap07.html#tag_07"><i>7. Locale</i></a> , <a href="../basedefs/V1_chap08.html#tag_08"><i>8.
    245 Environment Variables</i></a> , <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    246 </blockquote>
    247 <h4 class="mansect"><a name="tag_20_91_21" id="tag_20_91_21"></a>CHANGE HISTORY</h4>
    248 <blockquote>
    249 <p>First released in Issue 2.</p>
    250 </blockquote>
    251 <h4 class="mansect"><a name="tag_20_91_22" id="tag_20_91_22"></a>Issue 6</h4>
    252 <blockquote>
    253 <p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</p>
    254 </blockquote>
    255 <h4 class="mansect"><a name="tag_20_91_23" id="tag_20_91_23"></a>Issue 7</h4>
    256 <blockquote>
    257 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    258 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0149 [973] is applied.</p>
    259 </blockquote>
    260 <h4 class="mansect"><a name="tag_20_91_24" id="tag_20_91_24"></a>Issue 8</h4>
    261 <blockquote>
    262 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    263 </blockquote>
    264 <div class="box"><em>End of informative text.</em></div>
    265 <hr>
    266 <p>&nbsp;</p>
    267 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    268 <hr size="2" noshade>
    269 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    270 POSIX™ is a Trademark of The IEEE.<br>
    271 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    272 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    273 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    274 ]</font></center>
    275 <hr size="2" noshade>
    276 <div class="NAVHEADER">
    277 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    278 <tr class="nav">
    279 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/od.html" accesskey="P">&lt;&lt;&lt;
    280 Previous</a></td>
    281 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    282 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/patch.html" accesskey="N">Next
    283 &gt;&gt;&gt;</a></td>
    284 </tr>
    285 </table>
    286 <hr align="left" width="100%"></div>
    287 </body>
    288 </html>