Split File Into Smaller Multiple Files

This example will show how to TAR and GZIP a large file and split the file into smaller multiple files. First, TAR and GZIP the large file:

tar -czvf newlarge.tgz largefile.dat

After the that step is done you should now have a TGZ file named “newlarge.tgz”. Next, use the split command to split the files into multiple smaller files:

split -b 300m "newlarge.tgz" "newlarge.tgz.part-"

This command will create smaller files, with the prefix “newlarge.tgz.part-“. So using this example, if we spit a 1gb file the example would output these files:

newlarge.tgz.part-aa 
newlarge.tgz.part-ab 
newlarge.tgz.part-ac 
newlarge.tgz.part-ad

Finally, when you want to join the split files and extract the TAR and GZIP large file use this command:

cat newlarge* > newlarge.tgz

OR you can name each file individually:

cat newlarge.tgz.part-aa newlarge.tgz.part-ab newlarge.tgz.part-ac newlarge.tgz.part-ad > newlarge.tgz

Now the smaller files should be combined to build the “newlarge.tgz” file, which can now be extracted:

tar -xvf newlarge.tgz

Posted in Howto

Leave a Reply

Your email address will not be published. Required fields are marked *

*