I have 2 large files (of about 27 GB each), which I need to merge. They were originally one whole ZIP file, but I split it. The problem with the cat command is that it creates a new file which has the source files' content, which I do not want to do (since I don't have that much disk space left).

Is there an alternative to cat that supports merging files while simultaneously deleting the source files?

  • How did you split it? Would just concatenating the two files yield a valid Zip archive? – Kusalananda Feb 13 at 19:22
  • @Kusalananda I think so. I used the split command, by following this guide: howtoforge.com/tutorial/… – Avery Alejandro Feb 13 at 19:25
  • Do you have space under /tmp or elsewhere (/var?) that you could use temporarily? – Kusalananda Feb 13 at 19:29
  • @Kusalananda Yes I do have a /tmp directory, and I also have an 8 GB flash drive – Avery Alejandro Feb 13 at 19:35
  • How much free space in /tmp? (df -h /tmp) – Kusalananda Feb 13 at 19:39

(Summary of discussion)

You have 28.3 GB left in the partition that holds your current directory, and the second part of the archive is 27.8 GB. This means that you should be able to append the second part of the archive onto the first part of the archive.

Assuming the two parts are called part1 and part2:

cat part2 >>part1

After this, part1 would be the complete archive file (and part2 could be deleted).

The only issue is that there usually is a reserved buffer of space on a Unix filesystem that ordinary users can't fill (it's usually a few percent of the total partition size). Since the size restrictions here are so tight, I'm not entirely sure you would be within these size limits.

The remedy for that is either to run as the root user (who's not restricted in filling up the reserved space), or to simply clear out some large unneeded files.

To run as root, either bring up a root shell with sudo -s and run the cat as above, or do

sudo tee -a part1 <part2 >/dev/null
  • Okay, now time to figure out how to extract this ZIP file with the little disk space I have left... – Avery Alejandro Feb 13 at 20:05
  • @AveryAlejandro It would be difficult. If the contents is compressed, then it would be very difficult. That's all I can say. – Kusalananda Feb 13 at 20:06
  • They're not compressed. It's just stored – Avery Alejandro Feb 13 at 20:07
  • @AveryAlejandro You would have to find another 60 GB of space, and extract thing to there, or copy the archive there and extract from there. – Kusalananda Feb 13 at 20:08
  • 1
    @AveryAlejandro Sacrifices were made... – Kusalananda Feb 13 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.