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

NAME

6       split - split files into pieces
7

SYNOPSIS

9       split [-l line_count][-a suffix_length][file[name]]
10
11       split -b n[k|m][-a suffix_length][file[name]]
12
13

DESCRIPTION

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

OPTIONS

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

OPERANDS

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

STDIN

79       See the INPUT FILES section.
80

INPUT FILES

82       Any file can be used as input.
83

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

112       Default.
113

STDOUT

115       Not used.
116

STDERR

118       The standard error shall be used only for diagnostic messages.
119

OUTPUT FILES

121       The  output  files  contain portions of the original input file; other‐
122       wise, unchanged.
123

EXTENDED DESCRIPTION

125       None.
126

EXIT STATUS

128       The following exit values shall be returned:
129
130        0     Successful completion.
131
132       >0     An error occurred.
133
134

CONSEQUENCES OF ERRORS

136       Default.
137
138       The following sections are informative.
139

APPLICATION USAGE

141       None.
142

EXAMPLES

144       In the following examples foo is a text file that contains 5000 lines.
145
146        1. Create five files, xaa, xab, xac, xad, and xae:
147
148
149           split foo
150
151        2. Create five files, but the suffixed portion of  the  created  files
152           consists of three letters, xaaa, xaab, xaac, xaad, and xaae:
153
154
155           split -a 3 foo
156
157        3. Create three files with four-letter suffixes and a supplied prefix,
158           bar_aaaa, bar_aaab, and bar_aaac:
159
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
167           split -a 5 -b 20k foo
168

RATIONALE

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

FUTURE DIRECTIONS

192       None.
193

SEE ALSO

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