3

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)

2
  • 1
    Did you try with 4G ?
    – Maxime R.
    Dec 20, 2011 at 15:33
  • yes, just did, no difference Dec 20, 2011 at 15:47

2 Answers 2

4

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 -
1

split can't take more than one input file as an argument.

You can try using find for this

cd /var/lib/backuppc/images && find . -maxdepth 1 -type f -exec split -b 4G '{}' "/usbdrive/images/{}" \;
3
  • getting there, now getting: /usbdrive/images//var/lib/backuppc/images/Acer_Veriton_X498G_Desktop_Win_7_Pro_OA_FACTORY_BU.tibaa: No such file or directory (and my /usbdrive/images/ directory does exist) Dec 20, 2011 at 17:11
  • Sorry, forgot to take spaces into account, please see the edited command.
    – arrange
    Dec 20, 2011 at 17:57
  • Or, if you don't insist on split and preserving permissions etc, use 7z for example: 7z -v4g -mx0 a /usbdrive/images/images.7z /var/lib/backuppc/images.
    – arrange
    Dec 20, 2011 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .