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

📄 csplit.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 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-2003 The Open Group, All Rights Reserved --><title>csplit</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="csplit"></a> <a name="tag_04_29"></a><!-- csplit --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_29_01"></a>NAME</h4><blockquote>csplit - split files based on context</blockquote><h4><a name="tag_04_29_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('UP')">UP</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 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 arg1</i> <tt>...</tt><i>argn</i><tt><img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div></blockquote><h4><a name="tag_04_29_03"></a>DESCRIPTION</h4><blockquote><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 filesas directed by the <i>arg</i> operands, and write the sizes of the files.</p></blockquote><h4><a name="tag_04_29_04"></a>OPTIONS</h4><blockquote><p>The <i>csplit</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>-f&nbsp;</b> <i>prefix</i></dt><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> ...<b>xx</b> <i>n</i>. If the <i>prefix</i> argument would create a filename exceeding {NAME_MAX} bytes, an error shall result,<i>csplit</i> shall exit with a diagnostic message, and no files shall be created.</dd><dt><b>-k</b></dt><dd>Leave previously created files intact. By default, <i>csplit</i> shall remove created files if an error occurs.</dd><dt><b>-n&nbsp;</b> <i>number</i></dt><dd>Use <i>number</i> decimal digits to form filenames for the file pieces. The default shall be 2.</dd><dt><b>-s</b></dt><dd>Suppress the output of file size messages.</dd></dl></blockquote><h4><a name="tag_04_29_05"></a>OPERANDS</h4><blockquote><p>The following operands shall be supported:</p><dl compact><dt><i>file</i></dt><dd>The pathname of a text file to be split. If <i>file</i> is <tt>'-'</tt> , the standard input shall be used.</dd></dl><p>The operands <i>arg1</i> ... <i>argn</i> can be a combination of the following:</p><dl compact><dt>/<i>rexp</i>/<b>[</b><i>offset</i><b>]</b></dt><dd><br>A file shall be created using the content of the lines from the current line up to, but not including, the line that results fromthe evaluation of the regular expression with <i>offset</i>, if any, applied. The regular expression <i>rexp</i> shall follow therules for basic regular expressions described in the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap09.html#tag_09_03">Section 9.3, Basic Regular Expressions</a>. The application shall use the sequence<tt>"\/"</tt> to specify a slash character within the <i>rexp</i>. The optional offset shall be a positive or negative integervalue representing a number of lines. A positive integer 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 with zero lines, or one with greater than the number of lines left in theinput file, the results are unspecified. After the section is created, the current line shall be set to the line that results fromthe evaluation of the regular expression with any offset applied. If the current line is the first line in the file and a regularexpression operation has not yet been performed, the pattern match of <i>rexp</i> shall be applied from the current line to the endof the file. Otherwise, the pattern match of <i>rexp</i> shall be applied from the line following the current line to the end ofthe file.</dd><dt>%<i>rexp</i>%<b>[</b><i>offset</i><b>]</b></dt><dd><br>Equivalent to /<i>rexp</i>/<b>[</b><i>offset</i><b>]</b>, except that no file shall be created for the selected section of theinput file. The application shall use the sequence <tt>"\%"</tt> to specify a percent-sign character within the <i>rexp</i>.</dd><dt><i>line_no</i></dt><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 benumbered starting at one. The current line becomes <i>line_no</i>.</dd><dt>{<i>num</i>}</dt><dd>Repeat operand. This operand can follow any of the operands described previously. If it follows a <i>rexp</i> type operand,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<i>line_no</i> lines, <i>num</i> times, from that point.</dd></dl><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></blockquote><h4><a name="tag_04_29_06"></a>STDIN</h4><blockquote><p>See the INPUT FILES section.</p></blockquote><h4><a name="tag_04_29_07"></a>INPUT FILES</h4><blockquote><p>The input file shall be a text file.</p></blockquote><h4><a name="tag_04_29_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>csplit</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_COLLATE</i></dt><dd><br>Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regularexpressions.</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) and the behavior of character classes within regularexpressions.</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_29_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>If the <b>-k</b> option is specified, created files shall be retained. Otherwise, the default action occurs.</p></blockquote><h4><a name="tag_04_29_10"></a>STDOUT</h4><blockquote><p>Unless the <b>-s</b> option is used, the standard output shall consist of one line per file created, with a format asfollows:</p><pre><tt>"%d\n", &lt;</tt><i>file size in bytes</i><tt>&gt;</tt></pre></blockquote><h4><a name="tag_04_29_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_29_12"></a>OUTPUT FILES</h4><blockquote><p>The output files shall contain portions of the original input file; otherwise, unchanged.</p></blockquote><h4><a name="tag_04_29_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_29_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_29_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>By default, created files shall be removed if an error occurs. When the <b>-k</b> option is specified, created files shall notbe removed if an error occurs.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_29_16"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_29_17"></a>EXAMPLES</h4><blockquote><ol><li><p>This example creates four files, <b>cobol00</b> ... <b>cobol03</b>:</p><pre><tt>csplit -f cobol file '/procedure division/' /par5./ /par16./</tt></pre><p>After editing the split files, they can be recombined as follows:</p><pre><tt>cat cobol0[0-3] &gt; file</tt></pre><p>Note that this example overwrites the original file.</p></li><li><p>This example would split the file after the first 99 lines, and every 100 lines thereafter, up to 9999 lines; this is becauselines in the file are numbered from 1 rather than zero, for historical reasons:</p><pre><tt>csplit -k file  100  {99}</tt></pre></li><li><p>Assuming that <b>prog.c</b> follows the C-language coding convention of ending routines with a <tt>'}'</tt> at the beginning ofthe line, this example creates a file containing each separate C routine (up to 21) in <b>prog.c</b>:</p><pre><tt>csplit -k prog.c '%main(%'  '/^}/+1' {20}</tt></pre></li></ol></blockquote><h4><a name="tag_04_29_18"></a>RATIONALE</h4><blockquote><p>The <b>-n</b> option was added to extend the range of filenames that could be handled.</p><p>Consideration was given to adding a <b>-a</b> flag to use the alphabetic filename generation used by the historical <a href="../utilities/split.html"><i>split</i></a> utility, but the functionality added by the <b>-n</b> option was deemed to makealphabetic naming unnecessary.</p></blockquote><h4><a name="tag_04_29_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_29_20"></a>SEE ALSO</h4><blockquote><p><a href="sed.html"><i>sed</i></a> , <a href="split.html"><i>split</i></a></p></blockquote><h4><a name="tag_04_29_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_29_22"></a>Issue 5</h4><blockquote><p>The FUTURE DIRECTIONS section is added.</p></blockquote><h4><a name="tag_04_29_23"></a>Issue 6</h4><blockquote><p>This utility is marked as part of the User Portability Utilities option.</p><p>The APPLICATION USAGE section is added.</p><p>The description of regular expression operands is changed to align with the IEEE&nbsp;P1003.2b draft standard.</p><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><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 + -