split

From Initq

Jump to: navigation, search

split is a Unix utility most commonly used to split a file into two or more smaller files.

Usage

The command-syntax is:

split (optional parameters) (input filename) (output filename)

The default behavior of split is to generate output files of up to 1000 lines. The files are named by appending aa, ab, ac, etc. to output filename. If output filename is not given, the default filename of x is used, for example, xaa, xab, etc. When a hyphen (-) is used instead of input filename, data is derived from standard input.

To join the files back together again use the Cat (Unix)|cat command

cat xaa xab xac > filename

or

cat xa[a-c] > filename

Split is an excellent utility to use on binary files to split and transfer if you don't have compress or wanted to hide a slip file at different places. You have to be careful though. Use the -C flag to split binary files and not the -b byte-size flag.

-b, --bytes=SIZE
             put SIZE bytes per output file
-C, --line-bytes=SIZE
             put at most SIZE bytes of lines per output file
-d, --numeric-suffixes
             use numeric suffixes instead of alphabetic

-C flag will not split files without breaking lines across files.

Personal tools