isposix

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

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

split.html (14808B)


      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>split</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/sort.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/strings.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="split" id="split"></a> <a name="tag_20_113" id="tag_20_113"></a><!-- split -->
     29 <h4 class="mansect"><a name="tag_20_113_01" id="tag_20_113_01"></a>NAME</h4>
     30 <blockquote>split — split a file into pieces</blockquote>
     31 <h4 class="mansect"><a name="tag_20_113_02" id="tag_20_113_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <p><code><tt>split</tt> <b>[</b><tt>-l</tt> <i>line_count</i><b>] [</b><tt>-a</tt> <i>suffix_length</i><b>] [</b><i>file</i>
     34 <b>[</b><i>name</i><b>]]</b> <tt><br>
     35 <br>
     36 split -b</tt> <i>n</i><b>[</b><tt>k|m</tt><b>] [</b><tt>-a</tt> <i>suffix_length</i><b>] [</b><i>file</i>
     37 <b>[</b><i>name</i><b>]]</b> <tt><br></tt></code></p>
     38 </blockquote>
     39 <h4 class="mansect"><a name="tag_20_113_03" id="tag_20_113_03"></a>DESCRIPTION</h4>
     40 <blockquote>
     41 <p>The <i>split</i> utility shall read an input file and write zero or more output files. The default size of each output file
     42 shall be 1000 lines. The size of the output files can be modified by specification of the <b>-b</b> or <b>-l</b> options. Each
     43 output file shall be created with a unique suffix. The suffix shall consist of exactly <i>suffix_length</i> lowercase letters from
     44 the POSIX locale. The letters of the suffix shall be used as if they were a base-26 digit system, with the first suffix to be
     45 created consisting of all <tt>'a'</tt> characters, the second with a <tt>'b'</tt> replacing the last <tt>'a'</tt>, and so on, until
     46 a name of all <tt>'z'</tt> characters is created. By default, the names of the output files shall be <tt>'x'</tt>, followed by a
     47 two-character suffix from the character set as described above, starting with <tt>"aa"</tt>, <tt>"ab"</tt>, <tt>"ac"</tt>, and so
     48 on, and continuing until the suffix <tt>"zz"</tt>, for a maximum of 676 files.</p>
     49 <p>If the number of files required exceeds the maximum allowed by the suffix length provided, such that the last allowable file
     50 would be larger than the requested size, the <i>split</i> utility shall fail after creating the last file with a valid suffix;
     51 <i>split</i> shall not delete the files it created with valid suffixes. If the file limit is not exceeded, the last file created
     52 shall contain the remainder of the input file, and may be smaller than the requested size. If the input is an empty file, no output
     53 file shall be created and this shall not be considered to be an error.</p>
     54 </blockquote>
     55 <h4 class="mansect"><a name="tag_20_113_04" id="tag_20_113_04"></a>OPTIONS</h4>
     56 <blockquote>
     57 <p>The <i>split</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     58 Guidelines</i></a> .</p>
     59 <p>The following options shall be supported:</p>
     60 <dl compact>
     61 <dd></dd>
     62 <dt><b>-a&nbsp;</b><i>suffix_length</i></dt>
     63 <dd><br>
     64 Use <i>suffix_length</i> letters to form the suffix portion of the filenames of the split file. If <b>-a</b> is not specified, the
     65 default suffix length shall be two. If the sum of the <i>name</i> operand and the <i>suffix_length</i> option-argument would create
     66 a filename exceeding {NAME_MAX} bytes, an error shall result; <i>split</i> shall exit with a diagnostic message and no files shall
     67 be created.</dd>
     68 <dt><b>-b&nbsp;</b><i>n</i></dt>
     69 <dd>Split a file into pieces <i>n</i> bytes in size.</dd>
     70 <dt><b>-b&nbsp;</b><i>n</i><b>k</b></dt>
     71 <dd>Split a file into pieces <i>n</i>*1024 bytes in size.</dd>
     72 <dt><b>-b&nbsp;</b><i>n</i><b>m</b></dt>
     73 <dd>Split a file into pieces <i>n</i>*1048576 bytes in size.</dd>
     74 <dt><b>-l&nbsp;</b><i>line_count</i></dt>
     75 <dd>Specify the number of lines in each resulting file piece. The <i>line_count</i> argument is an unsigned decimal integer. The
     76 default is 1000. If the input does not end with a &lt;newline&gt;, the partial line shall be included in the last output file.</dd>
     77 </dl>
     78 </blockquote>
     79 <h4 class="mansect"><a name="tag_20_113_05" id="tag_20_113_05"></a>OPERANDS</h4>
     80 <blockquote>
     81 <p>The following operands shall be supported:</p>
     82 <dl compact>
     83 <dd></dd>
     84 <dt><i>file</i></dt>
     85 <dd>The pathname of the ordinary file to be split. If no input file is given or <i>file</i> is <tt>'-'</tt>, the standard input
     86 shall be used.</dd>
     87 <dt><i>name</i></dt>
     88 <dd>The prefix to be used for each of the files resulting from the split operation. If no <i>name</i> argument is given,
     89 <tt>'x'</tt> shall be used as the prefix of the output files. The combined length of the basename of <i>prefix</i> and
     90 <i>suffix_length</i> cannot exceed {NAME_MAX} bytes. See the OPTIONS section.</dd>
     91 </dl>
     92 </blockquote>
     93 <h4 class="mansect"><a name="tag_20_113_06" id="tag_20_113_06"></a>STDIN</h4>
     94 <blockquote>
     95 <p>See the INPUT FILES section.</p>
     96 </blockquote>
     97 <h4 class="mansect"><a name="tag_20_113_07" id="tag_20_113_07"></a>INPUT FILES</h4>
     98 <blockquote>
     99 <p>Any file can be used as input.</p>
    100 </blockquote>
    101 <h4 class="mansect"><a name="tag_20_113_08" id="tag_20_113_08"></a>ENVIRONMENT VARIABLES</h4>
    102 <blockquote>
    103 <p>The following environment variables shall affect the execution of <i>split</i>:</p>
    104 <dl compact>
    105 <dd></dd>
    106 <dt><i>LANG</i></dt>
    107 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    108 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    109 variables used to determine the values of locale categories.)</dd>
    110 <dt><i>LC_ALL</i></dt>
    111 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    112 <dt><i>LC_CTYPE</i></dt>
    113 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    114 opposed to multi-byte characters in arguments and input files).</dd>
    115 <dt><i>LC_MESSAGES</i></dt>
    116 <dd><br>
    117 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    118 <dt><i>NLSPATH</i></dt>
    119 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    120 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    121 "0"></dd>
    122 </dl>
    123 </blockquote>
    124 <h4 class="mansect"><a name="tag_20_113_09" id="tag_20_113_09"></a>ASYNCHRONOUS EVENTS</h4>
    125 <blockquote>
    126 <p>Default.</p>
    127 </blockquote>
    128 <h4 class="mansect"><a name="tag_20_113_10" id="tag_20_113_10"></a>STDOUT</h4>
    129 <blockquote>
    130 <p>Not used.</p>
    131 </blockquote>
    132 <h4 class="mansect"><a name="tag_20_113_11" id="tag_20_113_11"></a>STDERR</h4>
    133 <blockquote>
    134 <p>The standard error shall be used only for diagnostic messages.</p>
    135 </blockquote>
    136 <h4 class="mansect"><a name="tag_20_113_12" id="tag_20_113_12"></a>OUTPUT FILES</h4>
    137 <blockquote>
    138 <p>The output files contain portions of the original input file; otherwise, unchanged.</p>
    139 </blockquote>
    140 <h4 class="mansect"><a name="tag_20_113_13" id="tag_20_113_13"></a>EXTENDED DESCRIPTION</h4>
    141 <blockquote>
    142 <p>None.</p>
    143 </blockquote>
    144 <h4 class="mansect"><a name="tag_20_113_14" id="tag_20_113_14"></a>EXIT STATUS</h4>
    145 <blockquote>
    146 <p>The following exit values shall be returned:</p>
    147 <dl compact>
    148 <dd></dd>
    149 <dt>&nbsp;0</dt>
    150 <dd>Successful completion.</dd>
    151 <dt>&gt;0</dt>
    152 <dd>An error occurred.</dd>
    153 </dl>
    154 </blockquote>
    155 <h4 class="mansect"><a name="tag_20_113_15" id="tag_20_113_15"></a>CONSEQUENCES OF ERRORS</h4>
    156 <blockquote>
    157 <p>Default.</p>
    158 </blockquote>
    159 <hr>
    160 <div class="box"><em>The following sections are informative.</em></div>
    161 <h4 class="mansect"><a name="tag_20_113_16" id="tag_20_113_16"></a>APPLICATION USAGE</h4>
    162 <blockquote>
    163 <p>None.</p>
    164 </blockquote>
    165 <h4 class="mansect"><a name="tag_20_113_17" id="tag_20_113_17"></a>EXAMPLES</h4>
    166 <blockquote>
    167 <p>In the following examples <b>foo</b> is a text file that contains 5000 lines.</p>
    168 <ol>
    169 <li>
    170 <p>Create five files, <b>xaa</b>, <b>xab</b>, <b>xac</b>, <b>xad</b>, and <b>xae</b>:</p>
    171 <pre>
    172 <tt>split foo
    173 </tt></pre></li>
    174 <li>
    175 <p>Create five files, but the suffixed portion of the created files consists of three letters, <b>xaaa</b>, <b>xaab</b>,
    176 <b>xaac</b>, <b>xaad</b>, and <b>xaae</b>:</p>
    177 <pre>
    178 <tt>split -a 3 foo
    179 </tt></pre></li>
    180 <li>
    181 <p>Create three files with four-letter suffixes and a supplied prefix, <b>bar_aaaa</b>, <b>bar_aaab</b>, and <b>bar_aaac</b>:</p>
    182 <pre>
    183 <tt>split -a 4 -l 2000 foo bar_
    184 </tt></pre></li>
    185 <li>
    186 <p>Create as many files as are necessary to contain at most 20*1024 bytes, each with the default prefix of <b>x</b> and a
    187 five-letter suffix:</p>
    188 <pre>
    189 <tt>split -a 5 -b 20k foo
    190 </tt></pre></li>
    191 </ol>
    192 </blockquote>
    193 <h4 class="mansect"><a name="tag_20_113_18" id="tag_20_113_18"></a>RATIONALE</h4>
    194 <blockquote>
    195 <p>The <b>-b</b> option was added to provide a mechanism for splitting files other than by lines. While most uses of the <b>-b</b>
    196 option are for transmitting files over networks, some believed it would have additional uses.</p>
    197 <p>The <b>-a</b> option was added to overcome the limitation of being able to create only 676 files.</p>
    198 <p>Consideration was given to deleting this utility, using the rationale that the functionality provided by this utility is
    199 available via the <a href="../utilities/csplit.html"><i>csplit</i></a> utility (see <a href=
    200 "../utilities/csplit.html#"><i>csplit</i></a> ). Upon reconsideration of the purpose of the User Portability Utilities option, it
    201 was decided to retain both this utility and the <a href="../utilities/csplit.html"><i>csplit</i></a> utility because users use both
    202 utilities and have historical expectations of their behavior. Furthermore, the splitting on byte boundaries in <i>split</i> cannot
    203 be duplicated with the historical <a href="../utilities/csplit.html"><i>csplit</i></a>.</p>
    204 <p>The text &quot;<a href="../utilities/split.html"><i>split</i></a> shall not delete the files it created with valid suffixes&quot; would
    205 normally be assumed, but since the related utility, <a href="../utilities/csplit.html"><i>csplit</i></a>, does delete files under
    206 some circumstances, the historical behavior of <i>split</i> is made explicit to avoid misinterpretation.</p>
    207 <p>Earlier versions of this standard allowed a <b>-</b><i>line_count</i> option. This form is no longer specified by POSIX.1-2024
    208 but may be present in some implementations.</p>
    209 </blockquote>
    210 <h4 class="mansect"><a name="tag_20_113_19" id="tag_20_113_19"></a>FUTURE DIRECTIONS</h4>
    211 <blockquote>
    212 <p>If this utility is directed to create a new directory entry that contains any bytes that have the encoded value of a
    213 &lt;newline&gt; character, implementations are encouraged to treat this as an error. A future version of this standard may require
    214 implementations to treat this as an error.</p>
    215 </blockquote>
    216 <h4 class="mansect"><a name="tag_20_113_20" id="tag_20_113_20"></a>SEE ALSO</h4>
    217 <blockquote>
    218 <p><a href="../utilities/csplit.html#"><i>csplit</i></a></p>
    219 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    220 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    221 </blockquote>
    222 <h4 class="mansect"><a name="tag_20_113_21" id="tag_20_113_21"></a>CHANGE HISTORY</h4>
    223 <blockquote>
    224 <p>First released in Issue 2.</p>
    225 </blockquote>
    226 <h4 class="mansect"><a name="tag_20_113_22" id="tag_20_113_22"></a>Issue 6</h4>
    227 <blockquote>
    228 <p>This utility is marked as part of the User Portability Utilities option.</p>
    229 <p>The APPLICATION USAGE section is added.</p>
    230 <p>The obsolescent SYNOPSIS is removed.</p>
    231 </blockquote>
    232 <h4 class="mansect"><a name="tag_20_113_23" id="tag_20_113_23"></a>Issue 7</h4>
    233 <blockquote>
    234 <p>Austin Group Interpretation 1003.1-2001 #027 is applied.</p>
    235 <p>The <i>split</i> utility is moved from the User Portability Utilities option to the Base. User Portability Utilities is now an
    236 option for interactive utilities.</p>
    237 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    238 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0188 [731] is applied.</p>
    239 </blockquote>
    240 <h4 class="mansect"><a name="tag_20_113_24" id="tag_20_113_24"></a>Issue 8</h4>
    241 <blockquote>
    242 <p>Austin Group Defect 251 is applied, encouraging implementations to disallow the creation of filenames containing any bytes that
    243 have the encoded value of a &lt;newline&gt; character.</p>
    244 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    245 </blockquote>
    246 <div class="box"><em>End of informative text.</em></div>
    247 <hr>
    248 <p>&nbsp;</p>
    249 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    250 <hr size="2" noshade>
    251 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    252 POSIX™ is a Trademark of The IEEE.<br>
    253 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    254 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    255 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    256 ]</font></center>
    257 <hr size="2" noshade>
    258 <div class="NAVHEADER">
    259 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    260 <tr class="nav">
    261 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/sort.html" accesskey="P">&lt;&lt;&lt;
    262 Previous</a></td>
    263 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    264 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/strings.html" accesskey="N">Next
    265 &gt;&gt;&gt;</a></td>
    266 </tr>
    267 </table>
    268 <hr align="left" width="100%"></div>
    269 </body>
    270 </html>