Bash – Tar piped to split piped to scp

bashscpshellsplittar

So I'm trying to transfer a bunch of files via SCP. Some of these are too large to be stored on the recipient (Android phone, 4GB file size limit).

The sender is almost out of space, so I can't create intermediate files locally.

I'd like to tar up the bunch and stream it through split so that I can get smaller segments that'll be accepted by the phone, i.e. local command:

tar -cvf - ~/batch/ | split --bytes=1024m - batch.tar.seg

But I'm not sure how I'd pipe that into scp to get it the phone. According the comment on this post, it's possible, but I first of all don't quite get what he's saying, second of all I'm not sure how to accomplish this as there'll be multiple files output from split.

Any ideas?

Best Answer

If the recipient has split, then you can do:

tar -cvf - ~/batch/ | gzip |
  ssh recipient 'cd /destination &&
    split --bytes=1024m - batch.tar.gz.seg'
Related Question