# Ubuntu – How to split all the files in a directory in to 4gb files to a different directory

clipboardfilessplit

I have a directory containing several large files that are each greater than 4gb. I want to copy all of those files to a different directory (happens to be a fat32 usb drive mounted), but split the files down to 4gb (since the destination drive is limited to that size files).

I tried this:

split -b 4096G /var/lib/backuppc/images/* /usbdrive/


but I get a

split: extra operand /var/lib/backuppc/images/xxxxxxxxxmyfilesname.tib'


Am I doing something wrong? (also tried "4G" instead of 4096G, no difference)

• My suggestion would be to first create a tar file:

tar -cf /tmp/bigfile.tar /var/lib/backuppc/images/*


then split that:

cd /usbdrive
split -b 4G /tmp/bigfile.tar


If you want to avoid use of the temporary tar file you can pipe tar directly to split:

tar -cf - /var/lib/backuppc/images/* | split -b 4G


To reconstruct this when you get to the destination, recreate and unarchive the tar file:

cat /usbdrive/x* >bigfile.tar
tar -xvf bigfile.tar


Again, to do this without the temporary file:

cat /usbdrive/x* | tar -xvf -
`