Primer on zip, unzip, pkzip.

So now you've just downloaded a whole bunch of zipfiles but don't want to unpack them just to make sure they're Okay. What's the solution? Use the -t option to test them:

$ unzip -t quake92p
Archive:  quake92p.zip
    testing: DEICE.EXE                OK
    testing: QUAKE92P.1               OK
    testing: README.TXT               OK
    testing: INSTALL.BAT              OK
    testing: QUAKE92P.DAT             OK
No errors detected in compressed data of quake92p.zip.

Here we tested only one, and the output is a little too verbose—we really want only the one-line summary for each archive. unzip supports both a -q option for various levels of quietness (the more q's, the quieter) and the concept of wildcards, both for the internal files and for the zipfiles themselves:

$ unzip -tq \*.zip
No errors detected in compressed data of arena2b-grr.zip.
No errors detected in compressed data of PngSuite.zip.
No errors detected in compressed data of libgr2-elf-install.zip.
No errors detected in compressed data of ppmz-7.3.zip.
arithc.c                bad CRC e220fe9c  (should be 1c24998c)
At least one error was detected in macm.zip.
No errors detected in compressed data of xfer-zip151.zip.
No errors detected in compressed data of quake091.zip.
No errors detected in compressed data of quake92p.zip.
No errors detected in compressed data of p93b2200.zip.
8 archives were successfully processed.
1 archive had fatal errors.

Note that the wildcard character (“*”) is escaped with a backslash (“\”). Most shells expand wildcards themselves, and if we allowed that, unzip would see the command line as a list of archives; it would treat the first one as the zipfile name and the rest as files to be tested within the first one. By escaping the wildcard, we allow unzip to do its own directory search and wildcard-matching—which, incidentally, has the advantage that Unix-style regular expressions (very powerful wildcards) can be used not only under Linux but under all of the operating systems for which unzip ports exist, even plain old DOS.

The other thing to notice is that one of the archives has an error in it. Perhaps there was a transmission error, or maybe the original was damaged when it was created; either way, the file arithc.c in macm.zip is probably not going to be usable. It's always good to know these sorts of things sooner rather than later.

There are quite a few other options and modifiers not covered here; a full tutorial would occupy most of this magazine. Fortunately, the unzip and zipinfo man pages (man unzip and man zipinfo) contain a complete listing of all of the options and examples for many of them. Unfortunately, Slackware 3.0 and earlier don't include the zipinfo man page. An abbreviated summary of zipinfo's options is available by typing unzip -Z . Similarly, a summary of most of unzip's options can be had simply by typing unzip with no parameters.

History, Acknowledgments, Pointers and the Future

unzip, zipinfo, zip and their kin were written by the Info-ZIP group, an Internet-based collection of strange beings from another universe who are currently scattered all over the planet. Yours truly (that would be me) is the principal author of unzip and zipinfo, but literally hundreds of people have contributed to them. Originally based on code by Samuel H. Smith, unzip has since been completely rewritten, with the exception of one routine which is no longer included by default. Nevertheless, we certainly owe him a debt of gratitude for getting us into this pickle. It would probably also be nice to mention the folks at PKWARE, whose PKZIP and PKUNZIP programs are the source of most of the DOS-originated zipfiles in the world. Note that Info-ZIP's programs are intended to be compatible with PKWARE's zipfiles, but they are not clones of PKWARE's programs. (For example, unzip recreates stored zipfile directory trees by default, whereas PKUNZIP requires a special option to do it.

Note also that while zip and gzip (sometimes called “GNU zip”) have similar names, a similar heritage—Jean-loup Gailly and Mark Adler are the co-authors of the latter and are also long-standing members of the Info-ZIP group—and the same compression engine, the two programs are basically incompatible. The same goes for unzip and gunzip. Jean-loup never foresaw the confusion that would arise from the similarity, and I was too late in suggesting the obvious, sick alternative (feather*) to get the name changed.

On a more serious note, the current version of unzip is 5.2, and 5.21 will be out by the time you read this. While everything discussed above works equally well with the previous version (5.12), there are various new features and other improvements that make 5.2 worth getting. You can find the latest public releases of source code and executables at UUNET's anonymous ftp site:

ftp://ftp.uu.net/pub/archiving/zip/ ftp://ftp.uu.net/pub/archiving/zip/UNIX/LINUX/

You can also find news, history, descriptions of certain weirdos, and pointers to other ftp sites around the world at the following web site:


Greg Roelofs escaped from the University of Chicago with a degree in astrophysics and fled screaming to Silicon Valley, where he now does really cool graphics and compression stuff for Philips Research. He joined Info-ZIP in the spring of 1990, shortly after the group formed, and under his dark influence the group has nearly achieved its goal of Total Universal Reconstructive Disintegration, lacking only a better acronym in order to complete their plans. He's also the father of the Cutest Baby in the Known Universe. He be reached by e-mail at newt@uchicago.edu or on the Web at quest.jpl.nasa.gov/Info-ZIP/people/greg/.

[ ---- this is a footnote ---- ] * So all of the archives on Sunsite would be...yes, you guessed it: tar'd and feather'd. Bwah ha ha ha ha ha ha! If only.


White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState