How to split zip file into multiple valid zip files?

Viewed 696

coreutils's split can split any files. Therefore, it can split a .zip file into multiple files. But the ouput files are not valid zip files any more. This can be a problem when other output files are not available, as a single output file can not be used on its own.

This case can happen, for example, in a slow network, only some files are downloaded but other files take more time to download. But users want to see the initial transfered file.

Is there a good/concise way to split a .zip file into multiple valid .zip files?

I could make my own shell script to unzip the input .zip file and the select the appropriate subsets to compress them into multiple .zip files.

But since this task should be commonly encounted, I am wondering if there is any better way to do so. Thanks.

1 Answers

The zip(1) utility can take an existing zip archive, and create a new one split up into multiple files. Example:

$ zip -U -s 100k -O new.zip old.zip

will split the zip file into 100 kilobyte files named new.z01, new.z02, ..., new.zip. Then unzip new.zip will automatically read the split files when extracting the archive. Sometimes missing split fragments can be recovered from; read up on the -F option.

Related