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)

enzotib
  • 92,255
  • 11
  • 164
  • 178
Scott Szretter
  • 11,613
  • 3
  • 16
  • 7

2 Answers2

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 -
roadmr
  • 33,892
  • 9
  • 80
  • 93
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/{}" \;
arrange
  • 14,727
  • 4
  • 42
  • 32
  • 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) – Scott Szretter Dec 20 '11 at 17:11
  • Sorry, forgot to take spaces into account, please see the edited command. – arrange Dec 20 '11 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 '11 at 18:55