1SPLIT(1P)                  POSIX Programmer's Manual                 SPLIT(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       split - split files into pieces
13

SYNOPSIS

15       split [-l line_count][-a suffix_length][file[name]]
16
17       split -b n[k|m][-a suffix_length][file[name]]
18
19

DESCRIPTION

21       The split utility shall read an input file and write one or more output
22       files.  The  default  size of each output file shall be 1000 lines. The
23       size of the output files can be modified by specification of the -b  or
24       -l options. Each output file shall be created with a unique suffix. The
25       suffix shall consist of exactly suffix_length  lowercase  letters  from
26       the  POSIX  locale.  The letters of the suffix shall be used as if they
27       were a base-26 digit system, with the first suffix to be  created  con‐
28       sisting of all 'a' characters, the second with a 'b' replacing the last
29       'a', and so on, until a name of  all  'z'  characters  is  created.  By
30       default, the names of the output files shall be 'x', followed by a two-
31       character suffix from the character set as  described  above,  starting
32       with "aa", "ab", "ac", and so on, and continuing until the suffix "zz",
33       for a maximum of 676 files.
34
35       If the number of files required exceeds the maximum allowed by the suf‐
36       fix  length provided, such that the last allowable file would be larger
37       than the requested size, the split utility shall  fail  after  creating
38       the  last file with a valid suffix; split shall not delete the files it
39       created with valid suffixes.  If the file limit is  not  exceeded,  the
40       last  file  created  shall contain the remainder of the input file, and
41       may be smaller than the requested size.
42

OPTIONS

44       The split utility shall conform  to  the  Base  Definitions  volume  of
45       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
46
47       The following options shall be supported:
48
49       -a  suffix_length
50
51              Use  suffix_length  letters  to  form  the suffix portion of the
52              filenames of the split file. If -a is not specified, the default
53              suffix  length  shall be two. If the sum of the name operand and
54              the  suffix_length  option-argument  would  create  a   filename
55              exceeding  {NAME_MAX}  bytes, an error shall result; split shall
56              exit with a diagnostic message and no files shall be created.
57
58       -b  n  Split a file into pieces n bytes in size.
59
60       -b  nk Split a file into pieces n*1024 bytes in size.
61
62       -b  nm Split a file into pieces n*1048576 bytes in size.
63
64       -l  line_count
65              Specify the number of lines in each resulting  file  piece.  The
66              line_count  argument is an unsigned decimal integer. The default
67              is 1000. If the input does not end with a <newline>, the partial
68              line shall be included in the last output file.
69
70

OPERANDS

72       The following operands shall be supported:
73
74       file   The  pathname of the ordinary file to be split. If no input file
75              is given or file is '-', the standard input shall be used.
76
77       name   The prefix to be used for each of the files resulting  from  the
78              split operation. If no name argument is given, 'x' shall be used
79              as the prefix of the output files. The combined  length  of  the
80              basename  of  prefix  and suffix_length cannot exceed {NAME_MAX}
81              bytes. See the OPTIONS section.
82
83

STDIN

85       See the INPUT FILES section.
86

INPUT FILES

88       Any file can be used as input.
89

ENVIRONMENT VARIABLES

91       The following environment  variables  shall  affect  the  execution  of
92       split:
93
94       LANG   Provide  a  default value for the internationalization variables
95              that are unset or null. (See  the  Base  Definitions  volume  of
96              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
97              ables for the precedence of internationalization variables  used
98              to determine the values of locale categories.)
99
100       LC_ALL If  set  to a non-empty string value, override the values of all
101              the other internationalization variables.
102
103       LC_CTYPE
104              Determine the locale for  the  interpretation  of  sequences  of
105              bytes  of  text  data as characters (for example, single-byte as
106              opposed to multi-byte characters in arguments and input files).
107
108       LC_MESSAGES
109              Determine the locale that should be used to  affect  the  format
110              and contents of diagnostic messages written to standard error.
111
112       NLSPATH
113              Determine the location of message catalogs for the processing of
114              LC_MESSAGES .
115
116

ASYNCHRONOUS EVENTS

118       Default.
119

STDOUT

121       Not used.
122

STDERR

124       The standard error shall be used only for diagnostic messages.
125

OUTPUT FILES

127       The output files contain portions of the original  input  file;  other‐
128       wise, unchanged.
129

EXTENDED DESCRIPTION

131       None.
132

EXIT STATUS

134       The following exit values shall be returned:
135
136        0     Successful completion.
137
138       >0     An error occurred.
139
140

CONSEQUENCES OF ERRORS

142       Default.
143
144       The following sections are informative.
145

APPLICATION USAGE

147       None.
148

EXAMPLES

150       In the following examples foo is a text file that contains 5000 lines.
151
152        1. Create five files, xaa, xab, xac, xad, and xae:
153
154
155           split foo
156
157        2. Create  five  files,  but the suffixed portion of the created files
158           consists of three letters, xaaa, xaab, xaac, xaad, and xaae:
159
160
161           split -a 3 foo
162
163        3. Create three files with four-letter suffixes and a supplied prefix,
164           bar_aaaa, bar_aaab, and bar_aaac:
165
166
167           split -a 4 -l 2000 foo bar_
168
169        4. Create  as  many  files as are necessary to contain at most 20*1024
170           bytes, each with the default prefix of x and a five-letter suffix:
171
172
173           split -a 5 -b 20k foo
174

RATIONALE

176       The -b option was added to provide  a  mechanism  for  splitting  files
177       other than by lines. While most uses of the -b option are for transmit‐
178       ting files over networks, some believed it would have additional uses.
179
180       The -a option was added to overcome the limitation  of  being  able  to
181       create only 676 files.
182
183       Consideration  was  given to deleting this utility, using the rationale
184       that the functionality provided by this utility is  available  via  the
185       csplit  utility  (see  csplit ). Upon reconsideration of the purpose of
186       the User Portability Extension, it was  decided  to  retain  both  this
187       utility  and  the  csplit  utility because users use both utilities and
188       have historical expectations of their behavior. Furthermore, the split‐
189       ting on byte boundaries in split cannot be duplicated with the histori‐
190       cal csplit.
191
192       The text " split shall not delete the files it created with valid  suf‐
193       fixes"  would  normally  be  assumed,  but  since  the related utility,
194       csplit, does delete files  under  some  circumstances,  the  historical
195       behavior of split is made explicit to avoid misinterpretation.
196

FUTURE DIRECTIONS

198       None.
199

SEE ALSO

201       csplit
202
204       Portions  of  this text are reprinted and reproduced in electronic form
205       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
206       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
207       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
208       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
209       event of any discrepancy between this version and the original IEEE and
210       The  Open Group Standard, the original IEEE and The Open Group Standard
211       is the referee document. The original Standard can be  obtained  online
212       at http://www.opengroup.org/unix/online.html .
213
214
215
216IEEE/The Open Group                  2003                            SPLIT(1P)
Impressum