I think the problem is that when I concatenate the zip files before unzipping they are not in order because zip only uses one leading zero. For fewer than 100 files, the following works.
cat myzip.z* > cat_myzip.zip
unzip cat_myzip.zip
Is there a way to sort the files correctly for cat without renaming them, or otherwise unzip the split archive?
For this answer I'm assuming the files are named myzip.z01
, ..., myzip.z99
, myzip.z100
, etc.
If you have a halfway-decent unzipper program, you can just specify the first file and it'll automatically switch to the next part when needed:
7z x myzip.z00
If the split isn't something done in the standard way (You maybe used dd
to split it instead of zipsplit
), you can sort the files using sort -V
("version" sorting):
find . -type f -maxdepth 1 -name 'myzip.z[0-9]*' -print0 |
sort -V -z |
xargs -0 cat > myzip-combined.zip
unzip myzip-combined.zip
If you're using Bash, you can specify the filenames using a brace expansion with a leading 0 for 01-99, and no leading zero for 100-250:
cat myzip.z{{01..99},{100..250}} > myzip-combined.zip
unzip myzip-combined.zip