How can you concatenate two huge files with very little spare disk space?
Suppose that you have two huge files (several GB) that you want to concatenate together, but that you have very little spare disk space (let's say a couple hundred MB).  That is, given `file1` and `file2`, you want to end up with a single file which is the result of concatenating `file1` and `file2` together byte-for-byte, and delete the original files.

You can't do the obvious `cat file2 >> file1; rm file2`, since in between the two operations, you'd run out of disk space.

Solutions on any and all platforms with free or non-free tools are welcome; this is a hypothetical problem I thought up while I was downloading a Linux ISO the other day, and the download got interrupted partway through due to a wireless hiccup.
How can you concatenate two huge files with very little spare disk space?
===

Suppose that you have two huge files (several GB) that you want to concatenate together, but that you have very little spare disk space (let's say a couple hundred MB).  That is, given `file1` and `file2`, you want to end up with a single file which is the result of concatenating `file1` and `file2` together byte-for-byte, and delete the original files.

You can't do the obvious `cat file2 >> file1; rm file2`, since in between the two operations, you'd run out of disk space.

Solutions on any and all platforms with free or non-free tools are welcome; this is a hypothetical problem I thought up while I was downloading a Linux ISO the other day, and the download got interrupted partway through due to a wireless hiccup.