SPLITS

Split a Binary File into Multiple Chunks


This page describes a program, splits, which splits a file into multiple pieces of a specified size.

NAME

splits – split a binary file into multiple chunks

SYNOPSIS

splits infile [ chunksize ]

DESCRIPTION

splits reads an input file infile (or standard input if infile is “-”) and creates multiple output files which consist of the contents of infile broken into sequential pieces of size chunksize, given in “K” (units of 1024 bytes). If no chunksize is specified, splits assumes an output file size of 100K (102400 bytes).

splits is useful when transmitting large binary files over unreliable modem links with uucp. An accidental disconnection during a transmission causes the loss of everything received up to that point, requiring the user to start over from scratch. Breaking the file into multiple chunks with splits means that a disconnection only requires re-sending the chunk being transmitted when the hang-up occurred; if a chunk size substantially smaller than the average time between disconnects is chosen, lost communication time will be minimised.

splits may also be used to split large files being sent by electronic mail into pieces small enough to pass through intermediate mail forwarding sites. Some Internet mailers cannot process messages larger than 64K. splits allows you to circumvent this limitation. When sending binary files through electronic mail, you'll also have to encode the output of splits with a program such as uuencode or base64 since some mail systems accept only 7 bit ASCII characters.

Finally, splits allows subdividing large files into pieces which fit on various kinds of removable media such as 1.44 megabyte floppy discs.

On Unix the collection of chunks created with splits can be reassembled with cat. Simply use:

       cat infile.* >infile

to concatenate all the chunks together into an output file identical to the original splits input file. MS-DOS users can use the:

       COPY /B infile1+...+infilen outfile

command to concatenate chunks created with splits.

When sending files in multiple chunks, it's wise to accompany the transmission with a checksum created, for example, with sum or md5, so that the recipient can verify that all the pieces were correctly received and assembled in the proper order.

OPTIONS

None.

FILES

If infile is “-splits obtains its input from standard input. In this case the output files are named StdIn.001, StdIn.002, etc.

BUGS

splits assumes it can allocate memory buffers as large as the chunk size and that it can read and write blocks that large. Surgery will be required if you wish to port it to 16 bit architectures.

splits must read input and write output files in binary mode, without any translation of end of line or end of file characters. The splits source code contains code conditional on WIN32 which sets binary mode on that system. If you're porting splits to another platform which distinguishes text and binary I/O (Unix systems do not), you'll need to add equivalent code to set binary I/O mode.

Download splits.zip (Zipped archive)

The program is provided as splits.zip, a Zipped archive containing an ready-to-run WIN32 command-line executable program, splits.exe (compiled using Microsoft Visual C++ 5.0), and in source code form along with a Makefile to build the program under Unix.

SEE ALSO

base64(1), cat(1), md5(1), split(1), sum(1), uucp(1), uuencode(1)

EXIT STATUS

splits returns status 0 if processing was completed without errors, 1 if an error occurs while splitting a file, and 2 if invalid command line arguments are given.

COPYING

This software is in the public domain. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided “as is” without express or implied warranty.


by John Walker
October 27th, 1998