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
11

NAME

13       split — split files into pieces
14

SYNOPSIS

16       split [−l line_count] [−a suffix_length] [file[name]]
17
18       split −b n[k|m] [−a suffix_length] [file[name]]
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       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines.
46
47       The following options shall be supported:
48
49       −a suffix_length
50                 Use  suffix_length  letters to form the suffix portion of the
51                 filenames of the split file. If  −a  is  not  specified,  the
52                 default  suffix  length  shall be two. If the sum of the name
53                 operand and the suffix_length option-argument would create  a
54                 filename  exceeding  {NAME_MAX} bytes, an error shall result;
55                 split shall exit with a diagnostic message and no files shall
56                 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
67                 default  is 1000. If the input does not end with a <newline>,
68                 the partial line shall be included in the last output file.
69

OPERANDS

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

STDIN

84       See the INPUT FILES section.
85

INPUT FILES

87       Any file can be used as input.
88

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

116       Default.
117

STDOUT

119       Not used.
120

STDERR

122       The standard error shall be used only for diagnostic messages.
123

OUTPUT FILES

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

EXTENDED DESCRIPTION

129       None.
130

EXIT STATUS

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

CONSEQUENCES OF ERRORS

139       Default.
140
141       The following sections are informative.
142

APPLICATION USAGE

144       None.
145

EXAMPLES

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

RATIONALE

169       The −b option was added to provide  a  mechanism  for  splitting  files
170       other than by lines. While most uses of the −b option are for transmit‐
171       ting files over networks, some believed it would have additional uses.
172
173       The −a option was added to overcome the limitation  of  being  able  to
174       create only 676 files.
175
176       Consideration  was  given to deleting this utility, using the rationale
177       that the functionality provided by this utility is  available  via  the
178       csplit  utility  (see  csplit).  Upon reconsideration of the purpose of
179       the User Portability Utilities option, it was decided  to  retain  both
180       this  utility  and  the csplit utility because users use both utilities
181       and have historical expectations of their  behavior.  Furthermore,  the
182       splitting  on  byte  boundaries  in split cannot be duplicated with the
183       historical csplit.
184
185       The text ``split shall not delete the files it created with valid  suf‐
186       fixes''  would  normally  be  assumed,  but  since the related utility,
187       csplit, does delete files  under  some  circumstances,  the  historical
188       behavior of split is made explicit to avoid misinterpretation.
189
190       Earlier  versions  of  this standard allowed a line_count option. This
191       form is no longer specified by POSIX.1‐2008 but may be present in  some
192       implementations.
193

FUTURE DIRECTIONS

195       None.
196

SEE ALSO

198       csplit
199
200       The  Base  Definitions  volume  of POSIX.1‐2008, Chapter 8, Environment
201       Variables, Section 12.2, Utility Syntax Guidelines
202
204       Portions of this text are reprinted and reproduced in  electronic  form
205       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
206       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
207       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
208       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
209       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
210       event of any discrepancy between this version and the original IEEE and
211       The  Open Group Standard, the original IEEE and The Open Group Standard
212       is the referee document. The original Standard can be  obtained  online
213       at http://www.unix.org/online.html .
214
215       Any  typographical  or  formatting  errors that appear in this page are
216       most likely to have been introduced during the conversion of the source
217       files  to  man page format. To report such errors, see https://www.ker
218       nel.org/doc/man-pages/reporting_bugs.html .
219
220
221
222IEEE/The Open Group                  2013                            SPLIT(1P)
Impressum