Is there a way to split a ZIP archive into into smaller zipfiles, where you don't have to make them into one big zipfile to unpack the smaller zipfiles?

For example: Split 25 GB file into 5 files of 5 GB each --> archive1.zip, ..., archive5.zip. Now I want to extract the data of the archive "archive1.zip" without creating the 25 GB zipfile again.

I know, there is zipsplit, but it only works up to 2 GB and I have files up to 100 GB.

Many thanks in advance


I'm afraid there is no way of doing what you want. if you have a huge zip file, you can split it into many smaller files using split, but then those files will not be valid .zip archives and cannot be decompressed. The format of the compressed archive requires a valid header and when you split the archive, the sub-files you create will not have it.

Think of this like having a very long screwdriver. You can cut this into smaller bits, but only the bit that has the screwdriver's head could still function as a screwdriver. You can't just pick one of the middle pieces and expect it to function as a tiny screwdriver.

I'm afraid you have no choice but to recreate the huge .zip and extract that.


How to split a zipfile into smaller zipfiles

There is a generic command in Linux actually called split. It supports extensions and a max size and even a max line numbers option:

   -a, --suffix-length=N
          generate suffixes of length N (default 2)

          append an additional SUFFIX to file names

   -b, --bytes=SIZE
          put SIZE bytes per output file

   -C, --line-bytes=SIZE
          put at most SIZE bytes of records per output file

   -d     use numeric suffixes starting at 0, not alphabetic

   -l, --lines=NUMBER
          put NUMBER lines/records per output file

And to put them together you can simply cat them. 3 examples:

cat f1 f2 f3 > original.zip
cat dir/* > original.zip
for file in *; do cat $file >>original.zip; done

Now I want to extract the data of the archive "archive1.zip" without creating the 25 GB zipfile again.

unzip -l ARCHIVE_NAME will list the files in a zip. This works on the whole zip to extract 1 file:

unzip -j file.zip "dir/in/archive/file.txt" 

and will restore "dir/in/archive/file.txt" in the current directory. I have not seen proof on this working on a part of the zip file. And then it will be a hit/miss scenario: the file might be partly inside the previous and following part. I doubt it is possible without recreating the file; but that could be done "on the fly".

  • I don't think what the OP asks for is possible. They want to be able to extract a single sub-zip file. So first create huge.zip, then split to n1.zip ... n100.zip and then only extract the data in e.g. 5.zip. This isn't possible since the split files will not be self contained. – terdon May 16 at 9:22
  • ah I missed that – Rinzwind May 16 at 9:34

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.