isposix

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

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

csplit.html (15095B)


      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>csplit</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/crontab.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/ctags.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="csplit" id="csplit"></a> <a name="tag_20_26" id="tag_20_26"></a><!-- csplit -->
     29 <h4 class="mansect"><a name="tag_20_26_01" id="tag_20_26_01"></a>NAME</h4>
     30 <blockquote>csplit — split files based on context</blockquote>
     31 <h4 class="mansect"><a name="tag_20_26_02" id="tag_20_26_02"></a>SYNOPSIS</h4>
     32 <blockquote class="synopsis">
     33 <p><code><tt>csplit</tt> <b>[</b><tt>-ks</tt><b>] [</b><tt>-f</tt> <i>prefix</i><b>] [</b><tt>-n</tt> <i>number</i><b>]</b> <i>file
     34 arg</i><tt>...</tt></code></p>
     35 </blockquote>
     36 <h4 class="mansect"><a name="tag_20_26_03" id="tag_20_26_03"></a>DESCRIPTION</h4>
     37 <blockquote>
     38 <p>The <i>csplit</i> utility shall read the file named by the <i>file</i> operand, write all or part of that file into other files
     39 as directed by the <i>arg</i> operands, and write the sizes of the files.</p>
     40 </blockquote>
     41 <h4 class="mansect"><a name="tag_20_26_04" id="tag_20_26_04"></a>OPTIONS</h4>
     42 <blockquote>
     43 <p>The <i>csplit</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax
     44 Guidelines</i></a> .</p>
     45 <p>The following options shall be supported:</p>
     46 <dl compact>
     47 <dd></dd>
     48 <dt><b>-f&nbsp;</b><i>prefix</i></dt>
     49 <dd>Name the created files <i>prefix</i><b>00</b>, <i>prefix</i><b>01</b>, ..., <i>prefixn</i>. The default is <b>xx00</b> ...
     50 <b>xx</b><i>n</i>. If the <i>prefix</i> argument would create a filename exceeding {NAME_MAX} bytes, an error shall result,
     51 <i>csplit</i> shall exit with a diagnostic message, and no files shall be created.</dd>
     52 <dt><b>-k</b></dt>
     53 <dd>Leave previously created files intact. By default, <i>csplit</i> shall remove created files if an error occurs.</dd>
     54 <dt><b>-n&nbsp;</b><i>number</i></dt>
     55 <dd>Use <i>number</i> decimal digits to form filenames for the file pieces. The default shall be 2.</dd>
     56 <dt><b>-s</b></dt>
     57 <dd>Suppress the output of file size messages.</dd>
     58 </dl>
     59 </blockquote>
     60 <h4 class="mansect"><a name="tag_20_26_05" id="tag_20_26_05"></a>OPERANDS</h4>
     61 <blockquote>
     62 <p>The following operands shall be supported:</p>
     63 <dl compact>
     64 <dd></dd>
     65 <dt><i>file</i></dt>
     66 <dd>The pathname of a text file to be split. If <i>file</i> is <tt>'-'</tt>, the standard input shall be used.</dd>
     67 </dl>
     68 <p>Each <i>arg</i> operand can be one of the following:</p>
     69 <dl compact>
     70 <dd></dd>
     71 <dt>/<i>rexp</i>/<b>[</b><i>offset</i><b>]</b></dt>
     72 <dd><br>
     73 A file shall be created using the content of the lines from the current line up to, but not including, the line that results from
     74 the evaluation of the regular expression with <i>offset</i>, if any, applied. The regular expression <i>rexp</i> shall follow the
     75 rules for basic regular expressions described in XBD <a href="../basedefs/V1_chap09.html#tag_09_03"><i>9.3 Basic Regular
     76 Expressions</i></a> . The application shall use the sequence <tt>"\/"</tt> to specify a &lt;slash&gt; character within the
     77 <i>rexp</i>. The optional offset shall be a positive or negative integer value representing a number of lines. A positive integer
     78 value can be preceded by <tt>'+'</tt>. If the selection of lines from an <i>offset</i> expression of this type would create a file
     79 with zero lines, or one with greater than the number of lines left in the input file, the results are unspecified. After the
     80 section is created, the current line shall be set to the line that results from the evaluation of the regular expression with any
     81 offset applied. If the current line is the first line in the file and a regular expression operation has not yet been performed,
     82 the pattern match of <i>rexp</i> shall be applied from the current line to the end of the file. Otherwise, the pattern match of
     83 <i>rexp</i> shall be applied from the line following the current line to the end of the file.</dd>
     84 <dt>%<i>rexp</i>%<b>[</b><i>offset</i><b>]</b></dt>
     85 <dd><br>
     86 Equivalent to /<i>rexp</i>/<b>[</b><i>offset</i><b>]</b>, except that no file shall be created for the selected section of the
     87 input file. The application shall use the sequence <tt>"\%"</tt> to specify a &lt;percent-sign&gt; character within the
     88 <i>rexp</i>.</dd>
     89 <dt><i>line_no</i></dt>
     90 <dd>Create a file from the current line up to (but not including) the line number <i>line_no</i>. Lines in the file shall be
     91 numbered starting at one. The current line becomes <i>line_no</i>.</dd>
     92 <dt>{<i>num</i>}</dt>
     93 <dd>Repeat operand. This operand can follow any of the operands described previously. If it follows a <i>rexp</i> type operand,
     94 that operand shall be applied <i>num</i> more times. If it follows a <i>line_no</i> operand, the file shall be split every
     95 <i>line_no</i> lines, <i>num</i> times, from that point.</dd>
     96 </dl>
     97 <p>An error shall be reported if an operand does not reference a line between the current position and the end of the file.</p>
     98 </blockquote>
     99 <h4 class="mansect"><a name="tag_20_26_06" id="tag_20_26_06"></a>STDIN</h4>
    100 <blockquote>
    101 <p>See the INPUT FILES section.</p>
    102 </blockquote>
    103 <h4 class="mansect"><a name="tag_20_26_07" id="tag_20_26_07"></a>INPUT FILES</h4>
    104 <blockquote>
    105 <p>The input file shall be a text file.</p>
    106 </blockquote>
    107 <h4 class="mansect"><a name="tag_20_26_08" id="tag_20_26_08"></a>ENVIRONMENT VARIABLES</h4>
    108 <blockquote>
    109 <p>The following environment variables shall affect the execution of <i>csplit</i>:</p>
    110 <dl compact>
    111 <dd></dd>
    112 <dt><i>LANG</i></dt>
    113 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    114 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    115 variables used to determine the values of locale categories.)</dd>
    116 <dt><i>LC_ALL</i></dt>
    117 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    118 <dt><i>LC_COLLATE</i></dt>
    119 <dd><br>
    120 Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regular
    121 expressions.</dd>
    122 <dt><i>LC_CTYPE</i></dt>
    123 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
    124 opposed to multi-byte characters in arguments and input files) and the behavior of character classes within regular
    125 expressions.</dd>
    126 <dt><i>LC_MESSAGES</i></dt>
    127 <dd><br>
    128 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    129 <dt><i>NLSPATH</i></dt>
    130 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    131 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    132 "0"></dd>
    133 </dl>
    134 </blockquote>
    135 <h4 class="mansect"><a name="tag_20_26_09" id="tag_20_26_09"></a>ASYNCHRONOUS EVENTS</h4>
    136 <blockquote>
    137 <p>If the <b>-k</b> option is specified, created files shall be retained. Otherwise, the default action occurs.</p>
    138 </blockquote>
    139 <h4 class="mansect"><a name="tag_20_26_10" id="tag_20_26_10"></a>STDOUT</h4>
    140 <blockquote>
    141 <p>Unless the <b>-s</b> option is used, the standard output shall consist of one line per file created, with a format as
    142 follows:</p>
    143 <pre>
    144 <tt>"%d\n", &lt;</tt><i>file size in bytes</i><tt>&gt;
    145 </tt></pre></blockquote>
    146 <h4 class="mansect"><a name="tag_20_26_11" id="tag_20_26_11"></a>STDERR</h4>
    147 <blockquote>
    148 <p>The standard error shall be used only for diagnostic messages.</p>
    149 </blockquote>
    150 <h4 class="mansect"><a name="tag_20_26_12" id="tag_20_26_12"></a>OUTPUT FILES</h4>
    151 <blockquote>
    152 <p>The output files shall contain portions of the original input file; otherwise, unchanged.</p>
    153 </blockquote>
    154 <h4 class="mansect"><a name="tag_20_26_13" id="tag_20_26_13"></a>EXTENDED DESCRIPTION</h4>
    155 <blockquote>
    156 <p>None.</p>
    157 </blockquote>
    158 <h4 class="mansect"><a name="tag_20_26_14" id="tag_20_26_14"></a>EXIT STATUS</h4>
    159 <blockquote>
    160 <p>The following exit values shall be returned:</p>
    161 <dl compact>
    162 <dd></dd>
    163 <dt>&nbsp;0</dt>
    164 <dd>Successful completion.</dd>
    165 <dt>&gt;0</dt>
    166 <dd>An error occurred.</dd>
    167 </dl>
    168 </blockquote>
    169 <h4 class="mansect"><a name="tag_20_26_15" id="tag_20_26_15"></a>CONSEQUENCES OF ERRORS</h4>
    170 <blockquote>
    171 <p>By default, created files shall be removed if an error occurs. When the <b>-k</b> option is specified, created files shall not
    172 be removed if an error occurs.</p>
    173 </blockquote>
    174 <hr>
    175 <div class="box"><em>The following sections are informative.</em></div>
    176 <h4 class="mansect"><a name="tag_20_26_16" id="tag_20_26_16"></a>APPLICATION USAGE</h4>
    177 <blockquote>
    178 <p>None.</p>
    179 </blockquote>
    180 <h4 class="mansect"><a name="tag_20_26_17" id="tag_20_26_17"></a>EXAMPLES</h4>
    181 <blockquote>
    182 <ol>
    183 <li>
    184 <p>This example creates four files, <b>cobol00</b> ... <b>cobol03</b>:</p>
    185 <pre>
    186 <tt>csplit -f cobol file '/procedure division/' /par5./ /par16./
    187 </tt></pre>
    188 <p>After editing the split files, they can be recombined as follows:</p>
    189 <pre>
    190 <tt>cat cobol0[0-3] &gt; file
    191 </tt></pre>
    192 <p>Note that this example overwrites the original file.</p>
    193 </li>
    194 <li>
    195 <p>This example would split the file after the first 99 lines, and every 100 lines thereafter, up to 9999 lines; this is because
    196 lines in the file are numbered from 1 rather than zero, for historical reasons:</p>
    197 <pre>
    198 <tt>csplit -k file  100  {99}
    199 </tt></pre></li>
    200 <li>
    201 <p>Assuming that <b>prog.c</b> follows the C-language coding convention of ending routines with a <tt>'}'</tt> at the beginning of
    202 the line, this example creates a file containing each separate C routine (up to 21) in <b>prog.c</b>:</p>
    203 <pre>
    204 <tt>csplit -k prog.c '%main(%'  '/^}/+1' {20}
    205 </tt></pre></li>
    206 </ol>
    207 </blockquote>
    208 <h4 class="mansect"><a name="tag_20_26_18" id="tag_20_26_18"></a>RATIONALE</h4>
    209 <blockquote>
    210 <p>The <b>-n</b> option was added to extend the range of filenames that could be handled.</p>
    211 <p>Consideration was given to adding a <b>-a</b> flag to use the alphabetic filename generation used by the historical <a href=
    212 "../utilities/split.html"><i>split</i></a> utility, but the functionality added by the <b>-n</b> option was deemed to make
    213 alphabetic naming unnecessary.</p>
    214 </blockquote>
    215 <h4 class="mansect"><a name="tag_20_26_19" id="tag_20_26_19"></a>FUTURE DIRECTIONS</h4>
    216 <blockquote>
    217 <p>If this utility is directed to create a new directory entry that contains any bytes that have the encoded value of a
    218 &lt;newline&gt; character, implementations are encouraged to treat this as an error. A future version of this standard may require
    219 implementations to treat this as an error.</p>
    220 </blockquote>
    221 <h4 class="mansect"><a name="tag_20_26_20" id="tag_20_26_20"></a>SEE ALSO</h4>
    222 <blockquote>
    223 <p><a href="../utilities/sed.html#"><i>sed</i></a> , <a href="../utilities/split.html#"><i>split</i></a></p>
    224 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    225 "../basedefs/V1_chap09.html#tag_09_03"><i>9.3 Basic Regular Expressions</i></a> , <a href=
    226 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    227 </blockquote>
    228 <h4 class="mansect"><a name="tag_20_26_21" id="tag_20_26_21"></a>CHANGE HISTORY</h4>
    229 <blockquote>
    230 <p>First released in Issue 2.</p>
    231 </blockquote>
    232 <h4 class="mansect"><a name="tag_20_26_22" id="tag_20_26_22"></a>Issue 5</h4>
    233 <blockquote>
    234 <p>The FUTURE DIRECTIONS section is added.</p>
    235 </blockquote>
    236 <h4 class="mansect"><a name="tag_20_26_23" id="tag_20_26_23"></a>Issue 6</h4>
    237 <blockquote>
    238 <p>This utility is marked as part of the User Portability Utilities option.</p>
    239 <p>The APPLICATION USAGE section is added.</p>
    240 <p>The description of regular expression operands is changed to align with the IEEE&nbsp;P1003.2b draft standard.</p>
    241 <p>The normative text is reworded to avoid use of the term &quot;must&quot; for application requirements.</p>
    242 </blockquote>
    243 <h4 class="mansect"><a name="tag_20_26_24" id="tag_20_26_24"></a>Issue 7</h4>
    244 <blockquote>
    245 <p>The <i>csplit</i> utility is moved from the User Portability Utilities option to the Base. User Portability Utilities is now an
    246 option for interactive utilities.</p>
    247 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    248 <p>The SYNOPSIS and OPERANDS sections are revised to use a single <i>arg</i> to split a file into two pieces.</p>
    249 </blockquote>
    250 <h4 class="mansect"><a name="tag_20_26_25" id="tag_20_26_25"></a>Issue 8</h4>
    251 <blockquote>
    252 <p>Austin Group Defect 251 is applied, encouraging implementations to disallow the creation of filenames containing any bytes that
    253 have the encoded value of a &lt;newline&gt; character.</p>
    254 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    255 </blockquote>
    256 <div class="box"><em>End of informative text.</em></div>
    257 <hr>
    258 <p>&nbsp;</p>
    259 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    260 <hr size="2" noshade>
    261 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    262 POSIX™ is a Trademark of The IEEE.<br>
    263 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    264 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    265 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    266 ]</font></center>
    267 <hr size="2" noshade>
    268 <div class="NAVHEADER">
    269 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    270 <tr class="nav">
    271 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/crontab.html" accesskey="P">&lt;&lt;&lt;
    272 Previous</a></td>
    273 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    274 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/ctags.html" accesskey="N">Next
    275 &gt;&gt;&gt;</a></td>
    276 </tr>
    277 </table>
    278 <hr align="left" width="100%"></div>
    279 </body>
    280 </html>