Next: , Previous: tail invocation, Up: Output of parts of files


5.3 split: Split a file into fixed-size pieces

split creates output files containing consecutive sections of input (standard input if none is given or input is ‘-’). Synopsis:

     split [option] [input [prefix]]

By default, split puts 1000 lines of input (or whatever is left over for the last section), into each output file.

The output files' names consist of prefix (‘x’ by default) followed by a group of characters (‘aa’, ‘ab’, ... by default), such that concatenating the output files in traditional sorted order by file name produces the original input file. If the output file names are exhausted, split reports an error without deleting the output files that it did create.

The program accepts the following options. Also see Common options.

-a length
--suffix-length=length
Use suffixes of length length. The default length is 2.
-l lines
--lines=lines
Put lines lines of input into each output file.

For compatibility split also supports an obsolete option syntax -lines. New scripts should use -l lines instead.

-b bytes
--bytes=bytes
Put the first bytes bytes of input into each output file. Appending ‘b’ multiplies bytes by 512, ‘k’ by 1024, and ‘m’ by 1048576.
-C bytes
--line-bytes=bytes
Put into each output file as many complete lines of input as possible without exceeding bytes bytes. For lines longer than bytes bytes, put bytes bytes into each output file until less than bytes bytes of the line are left, then continue normally. bytes has the same format as for the --bytes option.
-d
--numeric-suffixes
Use digits in suffixes rather than lower-case letters.
--verbose
Write a diagnostic to standard error just before each output file is opened.

An exit status of zero indicates success, and a nonzero value indicates failure.