Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create split zip files from the command line System 10.8

It appears that OSX 10.8 removed the tar --tape-length flag, and I see no other way to create split tar archives as described in this hint.

One alternative is to create split zip files using the zip tool provided with OS X.

As described in man zip, the resulting files are not just one big zip file that has been split into pieces, and thus they cannot gracefully be concatenated back together as described in another hint, so this differs from simply using the split command. I needed to send files to a Windows user with 7zip, so split was probably out of the question.

To get 4699717632 byte files that would fit on a DVD I used zip -s 4482m /source/directory

[kirkmc adds: I'm on the road with only my iPad, so I havent been able to test this.]
  • Currently 2.33 / 5
  You rated: 1 / 5 (6 votes cast)

Create split zip files from the command line | 8 comments | Create New Account
Click here to return to the 'Create split zip files from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create split zip files from the command line
Authored by: blubdog on Mar 20, '13 08:35:25PM

The -s parameter splits the archive into multiple zipped files fine, but how do I unzip them? Using unzip from the command only looks at the very last file in the archive, and when you specify the first file (.z01), it errors out with:

$ unzip bws.z01
Archive: bws.z01
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of bws.z01 or, and cannot find bws.z01.ZIP, period.

[ Reply to This | # ]
unzipping a split zip...
Authored by: chrisrosa on Mar 21, '13 12:23:03AM

The Unarchiver (free in MAS), unzips the split zip just fine, but hell if I can't find a way to get unzip at the command line to do the same thing.

[ Reply to This | # ]
Create split zip files from the command line
Authored by: penguintopia on Mar 21, '13 04:38:18AM

Why not create the zip file and then use the split command to make your chunks? Those files can simply be concatenated and unzipped.

[ Reply to This | # ]
Create split zip files from the command line
Authored by: Strod on Mar 21, '13 10:42:10AM
Exactly. The way to do this, after you create (note that I am taking the size of each segment from the article, 4482 MB):
split -b 4482m TheSegment
That will leave you with several files called TheSegmentaa, TheSegmentab, etc. To concatenate on a Mac:
cat TheSegment* >
And on the DOS prompt of a Windows machine (oh, the horror!):
type TheSegment* >
You can verify that all three big files are identical my getting the MD5 checksum or similar method (not sure how to do that on Windows without extra tools, though).

[ Reply to This | # ]
One word: Mom
Authored by: lullabud on Mar 21, '13 09:23:42PM

You and I could definitely do that, and that is certainly the way I would've gone if I wanted to split up a tgz file. My momů not so much, especially not on Windows. If she were using a Mac I probably would've gone with a sparse bundle DMG file.

As I mentioned in the OP, the man page for zip explains the difference between that approach and using the split zip method.

Split zip is just one alternative to this problem, and it happens to have built in support on both Windows and OS X.

Edited on Mar 21, '13 09:28:07PM by lullabud

[ Reply to This | # ]
Or use rar
Authored by: dronkert on Mar 21, '13 05:52:16AM

The rar command line tool can be downloaded as (never ending) trialware at Unrar is free on all platforms. Usage: "rar a -m0 -v4700000 archivename filename(s)" where a = add (create archive), -m0 = no compression (-m5 = max compression, not useful for video plus it takes much longer), -v with max size in KB (1000 bytes, append 'k' for size in 1024 bytes: -v4589843k).

[ Reply to This | # ]
Create split zip files from the command line
Authored by: kamath on Mar 21, '13 10:36:00PM

Uh, what?

"It appears that OSX 10.8 removed the tar --tape-length flag"

Not really. Our fine friends at Apple have chosen to remind us there are other versions of software beside that provided by GNU. Mac OS X appears to have moved 'tar' to be 'bsdtar' and gnu tar is now 'gnutar'. Actually, it's a symlink. Do 'ls -l /usr/bin/tar' to see.

Try this:

gnutar --tape-length=102400 -cMv --file=tar_archive.{tar,tar-{2..100}} [files to tar]

Note, I would *NOT* change the link to gnutar. There be dragons.

[ Reply to This | # ]
Many thanks!
Authored by: lullabud on Mar 24, '13 04:21:55PM

That is very helpful! I was a little taken aback when I found that normal 'tar' didn't have the --tape-length flag, even for historical purposes. Knowing about gnutar is very helpful, thanks for pointing it out!

[ Reply to This | # ]