1SPLIT(1P) POSIX Programmer's Manual SPLIT(1P)
2
3
4
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
12 split — split a file into pieces
13
15 split [-l line_count] [-a suffix_length] [file [name]]
16
17 split -b n[k|m] [-a suffix_length] [file [name]]
18
20 The split utility shall read an input file and write zero or more out‐
21 put files. The default size of each output file shall be 1000 lines.
22 The size of the output files can be modified by specification of the -b
23 or -l options. Each output file shall be created with a unique suffix.
24 The suffix shall consist of exactly suffix_length lowercase letters
25 from the POSIX locale. The letters of the suffix shall be used as if
26 they were a base-26 digit system, with the first suffix to be created
27 consisting of all 'a' characters, the second with a 'b' replacing the
28 last 'a', and so on, until a name of all 'z' characters is created. By
29 default, the names of the output files shall be 'x', followed by a two-
30 character suffix from the character set as described above, starting
31 with "aa", "ab", "ac", and so on, and continuing until the suffix "zz",
32 for a maximum of 676 files.
33
34 If the number of files required exceeds the maximum allowed by the suf‐
35 fix length provided, such that the last allowable file would be larger
36 than the requested size, the split utility shall fail after creating
37 the last file with a valid suffix; split shall not delete the files it
38 created with valid suffixes. If the file limit is not exceeded, the
39 last file created shall contain the remainder of the input file, and
40 may be smaller than the requested size. If the input is an empty file,
41 no output file shall be created and this shall not be considered to be
42 an error.
43
45 The split utility shall conform to the Base Definitions volume of
46 POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
47
48 The following options shall be supported:
49
50 -a suffix_length
51 Use suffix_length letters to form the suffix portion of the
52 filenames of the split file. If -a is not specified, the
53 default suffix length shall be two. If the sum of the name
54 operand and the suffix_length option-argument would create a
55 filename exceeding {NAME_MAX} bytes, an error shall result;
56 split shall exit with a diagnostic message and no files shall
57 be created.
58
59 -b n Split a file into pieces n bytes in size.
60
61 -b nk Split a file into pieces n*1024 bytes in size.
62
63 -b nm Split a file into pieces n*1048576 bytes in size.
64
65 -l line_count
66 Specify the number of lines in each resulting file piece. The
67 line_count argument is an unsigned decimal integer. The
68 default is 1000. If the input does not end with a <newline>,
69 the partial line shall be included in the last output file.
70
72 The following operands shall be supported:
73
74 file The pathname of the ordinary file to be split. If no input
75 file is given or file is '-', the standard input shall be
76 used.
77
78 name The prefix to be used for each of the files resulting from
79 the split operation. If no name argument is given, 'x' shall
80 be used as the prefix of the output files. The combined
81 length of the basename of prefix and suffix_length cannot
82 exceed {NAME_MAX} bytes. See the OPTIONS section.
83
85 See the INPUT FILES section.
86
88 Any file can be used as input.
89
91 The following environment variables shall affect the execution of
92 split:
93
94 LANG Provide a default value for the internationalization vari‐
95 ables that are unset or null. (See the Base Definitions vol‐
96 ume of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
97 ables for the precedence of internationalization variables
98 used to determine the values of locale categories.)
99
100 LC_ALL If set to a non-empty string value, override the values of
101 all the other internationalization variables.
102
103 LC_CTYPE Determine the locale for the interpretation of sequences of
104 bytes of text data as characters (for example, single-byte as
105 opposed to multi-byte characters in arguments and input
106 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
111 error.
112
113 NLSPATH Determine the location of message catalogs for the processing
114 of LC_MESSAGES.
115
117 Default.
118
120 Not used.
121
123 The standard error shall be used only for diagnostic messages.
124
126 The output files contain portions of the original input file; other‐
127 wise, unchanged.
128
130 None.
131
133 The following exit values shall be returned:
134
135 0 Successful completion.
136
137 >0 An error occurred.
138
140 Default.
141
142 The following sections are informative.
143
145 None.
146
148 In the following examples foo is a text file that contains 5000 lines.
149
150 1. Create five files, xaa, xab, xac, xad, and xae:
151
152
153 split foo
154
155 2. Create five files, but the suffixed portion of the created files
156 consists of three letters, xaaa, xaab, xaac, xaad, and xaae:
157
158
159 split -a 3 foo
160
161 3. Create three files with four-letter suffixes and a supplied prefix,
162 bar_aaaa, bar_aaab, and bar_aaac:
163
164
165 split -a 4 -l 2000 foo bar_
166
167 4. Create as many files as are necessary to contain at most 20*1024
168 bytes, each with the default prefix of x and a five-letter suffix:
169
170
171 split -a 5 -b 20k foo
172
174 The -b option was added to provide a mechanism for splitting files
175 other than by lines. While most uses of the -b option are for transmit‐
176 ting files over networks, some believed it would have additional uses.
177
178 The -a option was added to overcome the limitation of being able to
179 create only 676 files.
180
181 Consideration was given to deleting this utility, using the rationale
182 that the functionality provided by this utility is available via the
183 csplit utility (see csplit). Upon reconsideration of the purpose of
184 the User Portability Utilities option, it was decided to retain both
185 this utility and the csplit utility because users use both utilities
186 and have historical expectations of their behavior. Furthermore, the
187 splitting on byte boundaries in split cannot be duplicated with the
188 historical csplit.
189
190 The text ``split shall not delete the files it created with valid suf‐
191 fixes'' would normally be assumed, but since the related utility,
192 csplit, does delete files under some circumstances, the historical
193 behavior of split is made explicit to avoid misinterpretation.
194
195 Earlier versions of this standard allowed a -line_count option. This
196 form is no longer specified by POSIX.1‐2008 but may be present in some
197 implementations.
198
200 None.
201
203 csplit
204
205 The Base Definitions volume of POSIX.1‐2017, Chapter 8, Environment
206 Variables, Section 12.2, Utility Syntax Guidelines
207
209 Portions of this text are reprinted and reproduced in electronic form
210 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
211 table Operating System Interface (POSIX), The Open Group Base Specifi‐
212 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
213 Electrical and Electronics Engineers, Inc and The Open Group. In the
214 event of any discrepancy between this version and the original IEEE and
215 The Open Group Standard, the original IEEE and The Open Group Standard
216 is the referee document. The original Standard can be obtained online
217 at http://www.opengroup.org/unix/online.html .
218
219 Any typographical or formatting errors that appear in this page are
220 most likely to have been introduced during the conversion of the source
221 files to man page format. To report such errors, see https://www.ker‐
222 nel.org/doc/man-pages/reporting_bugs.html .
223
224
225
226IEEE/The Open Group 2017 SPLIT(1P)