Rate this page del.icio.us  Digg slashdot StumbleUpon

How can I split a file into several smaller pieces?

by

Release Found: Red Hat Enterprise Linux 3 and Red Hat Enterprise Linux 4

Solution:
Cutting down or splitting a file to several smaller pieces have great benefits. A large file split into several smaller files can easilly fit in a CD or floppy disk or even transferred over the network. Splitting the file is possible using the split command.

Below is an example on how to use the split command:

Using split on a 5.3MB image.iso file:

split -b 1400k image.iso

It will generate 4 files with the following file sizes:

1404k xaa
1404k xab
1404k xac
1208k xad

To recreate the file, the cat command can be
used.

cat xa* > new-image.iso

The split and cat commands are provided by the coreutils package. Once the new new-image.iso file is restored, its possible to delete the other split files.

Note: To verify that the file has been correctly restored, use the command md5sum before and after splitting the file. Syntax:

md5sum [filename]

contributed by Michael Napolis

Red Hat’s customer service and support teams receive technical support questions from users all over the world. Red Hat technicians add the questions and answers to Red Hat Knowledgebase on a daily basis. Access to Red Hat Knowledgebase is free. Every month, Red Hat Magazine offers a preview into the Red Hat Knowledgebase by highlighting some of the most recent entries.

2 responses to “How can I split a file into several smaller pieces?”

  1. Richard Jones says:

    Back in the day (by which I mean around 1989) Minix had a wonderful command called ‘vol’ which you could use to split a file over floppy disks, tapes, etc. or alternately reconstruct them.

    IIRC, usage was something along the lines of:

    vol bigfile device [size]

    eg:

    tar cf – / | compress | vol – /dev/tape

    ‘vol’ would prompt you to insert each floppy device. A command like this could still be useful today – eg. for backing up onto flash devices.

  2. Petri T. Koistinen says:

    Using sha1sum instead of md5sum would be more secure. =)