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.
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:
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 email@example.com 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.
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
|Dart: a New Web Programming Experience||May 07, 2013|
- RSS Feeds
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Validate an E-Mail Address with PHP, the Right Way
- New Products
- Developer Poll
- Trying to Tame the Tablet
- not living upto the mobile revolution
1 hour 33 min ago
- Deceptive Advertising and
2 hours 9 min ago
- Let\'s declare that you have
2 hours 10 min ago
- Alterations in Contest Due
2 hours 11 min ago
- At a numbers mindset, your
2 hours 12 min ago
- Do not get Just Almost any
2 hours 16 min ago
- A fantastic rule-of-thumb to
2 hours 17 min ago
- Keren mastah..
3 hours 15 min ago
- mini tablet compare
4 hours 34 min ago
- Looking Good
8 hours 7 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.