330 lines
11 KiB
HTML
330 lines
11 KiB
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 The Open Group, All Rights Reserved -->
|
|
<title>split</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="split"></a> <a name="tag_04_132"></a><!-- split -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_132_01"></a>NAME</h4>
|
|
|
|
<blockquote>split - split files into pieces</blockquote>
|
|
|
|
<h4><a name="tag_04_132_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"> 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><b>[</b><i>name</i><b>]]</b><tt><br>
|
|
<br>
|
|
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><b>[</b><i>name</i><b>]]</b><tt><img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_04_132_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>split</i> utility shall read an input file and write one or more output files. The default size of each output file 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 output
|
|
file shall be created with a unique suffix. The suffix shall consist of exactly <i>suffix_length</i> lowercase letters from 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 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 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
|
|
two-character suffix from the character set as described above, starting with <tt>"aa"</tt> , <tt>"ab"</tt> , <tt>"ac"</tt> , and
|
|
so on, and continuing until the suffix <tt>"zz"</tt> , for a maximum of 676 files.</p>
|
|
|
|
<p>If the number of files required exceeds the maximum allowed by the suffix length provided, such that the last allowable file
|
|
would be larger than the requested size, the <i>split</i> utility shall fail after creating the last file with a valid suffix;
|
|
<i>split</i> shall not delete the files it created with valid suffixes. If the file limit is not exceeded, the last file created
|
|
shall contain the remainder of the input file, and may be smaller than the requested size.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>split</i> utility shall conform to the Base Definitions volume of IEEE Std 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>-a </b> <i>suffix_length</i></dt>
|
|
|
|
<dd><br>
|
|
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
|
|
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
|
|
a filename exceeding {NAME_MAX} bytes, an error shall result; <i>split</i> shall exit with a diagnostic message and no files shall
|
|
be created.</dd>
|
|
|
|
<dt><b>-b </b> <i>n</i></dt>
|
|
|
|
<dd>Split a file into pieces <i>n</i> bytes in size.</dd>
|
|
|
|
<dt><b>-b </b> <i>n</i><b>k</b></dt>
|
|
|
|
<dd>Split a file into pieces <i>n</i>*1024 bytes in size.</dd>
|
|
|
|
<dt><b>-b </b> <i>n</i><b>m</b></dt>
|
|
|
|
<dd>Split a file into pieces <i>n</i>*1048576 bytes in size.</dd>
|
|
|
|
<dt><b>-l </b> <i>line_count</i></dt>
|
|
|
|
<dd>Specify the number of lines in each resulting file piece. The <i>line_count</i> argument is an unsigned decimal integer. The
|
|
default is 1000. If the input does not end with a <newline>, the partial line shall be included in the last output file.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operands shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>file</i></dt>
|
|
|
|
<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
|
|
shall be used.</dd>
|
|
|
|
<dt><i>name</i></dt>
|
|
|
|
<dd>The prefix to be used for each of the files resulting from the split operation. If no <i>name</i> argument is given,
|
|
<tt>'x'</tt> shall be used as the prefix of the output files. The combined length of the basename of <i>prefix</i> and
|
|
<i>suffix_length</i> cannot exceed {NAME_MAX} bytes. See the OPTIONS section.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>See the INPUT FILES section.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>Any file can be used as input.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>split</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 of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the 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_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments and input files).</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 standard
|
|
error.</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_132_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>Not used.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>The output files contain portions of the original input file; otherwise, unchanged.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>Successful completion.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_132_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>In the following examples <b>foo</b> is a text file that contains 5000 lines.</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>Create five files, <b>xaa</b>, <b>xab</b>, <b>xac</b>, <b>xad</b>, and <b>xae</b>:</p>
|
|
|
|
<pre>
|
|
<tt>split foo
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Create five files, but the suffixed portion of the created files consists of three letters, <b>xaaa</b>, <b>xaab</b>,
|
|
<b>xaac</b>, <b>xaad</b>, and <b>xaae</b>:</p>
|
|
|
|
<pre>
|
|
<tt>split -a 3 foo
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<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>
|
|
|
|
<pre>
|
|
<tt>split -a 4 -l 2000 foo bar_
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<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
|
|
five-letter suffix:</p>
|
|
|
|
<pre>
|
|
<tt>split -a 5 -b 20k foo
|
|
</tt>
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<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>
|
|
option are for transmitting files over networks, some believed it would have additional uses.</p>
|
|
|
|
<p>The <b>-a</b> option was added to overcome the limitation of being able to create only 676 files.</p>
|
|
|
|
<p>Consideration was given to deleting this utility, using the rationale that the functionality provided by this utility is
|
|
available via the <a href="../utilities/csplit.html"><i>csplit</i></a> utility (see <a href="csplit.html"><i>csplit</i></a> ). Upon
|
|
reconsideration of the purpose of the User Portability Extension, it was decided to retain both this utility and the <a href=
|
|
"../utilities/csplit.html"><i>csplit</i></a> utility because users use both utilities and have historical expectations of their
|
|
behavior. Furthermore, the splitting on byte boundaries in <i>split</i> cannot be duplicated with the historical <a href=
|
|
"../utilities/csplit.html"><i>csplit</i></a>.</p>
|
|
|
|
<p>The text " <i>split</i> shall not delete the files it created with valid suffixes" would normally be assumed, but since the
|
|
related utility, <a href="../utilities/csplit.html"><i>csplit</i></a>, does delete files under some circumstances, the historical
|
|
behavior of <i>split</i> is made explicit to avoid misinterpretation.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="csplit.html"><i>csplit</i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_132_22"></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 obsolescent SYNOPSIS is removed.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® 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>
|
|
|