The split command does what it says: It splits a file into parts. By default it splits the file into pieces, each of which has 1,000 lines with names xaa, xab, xac, and so on. The split command can also be used to split up a binary file into equal sized pieces; this can be useful in those cases where for some reason the only way to get a file off a machine is to copy it to a floppy disk or USB drive, but the file is too big. To reassemble the file, use cat. Consider the following examples:
[email protected]:~ > split -l 100000 ARCHIVES
This first example splits the file ARCHIVES into pieces with 100,000 lines each, with names xaa, xab, xac, and so on.
[email protected]:~ > split -b 1024k kernel-source-2.6.4-52.i586.rpm
This second example splits the file kernel-source-2.6.4-52.i 586.rpm into pieces 1 MB in size with names xaa, xab, xac, and so on. Assuming that these files have all been copied into a directory elsewhere, to reassemble the original file, you simply use the following command:
Because the shell interprets the x* as a list of all matching files in alphabetical order, the files will be concatenated in the right order and the result will be identical to the original.
Was this article helpful?