The unix-way and unzip

The whole world use ZIP package format. Nothing can be done, that is the fact. This poor compression format got famous thanks to the WinZIP utility and tons of its clones.

We, Linux and UNIX fans, use tarballs. This name was generalized and estabilished as a term for all compresset tar files. The most famous compression programs are gzip, bzip2 or the old guy named compress. All the utilities I just mentioned above works the UNIX WAY(TM).

Today I needed to unzip several zip files and I issued "typical" UNIX command:

# unzip *zip
caution: filename not matched:
caution: filename not matched:
caution: filename not matched:
caution: filename not matched:

Oh, it happens again. I am not able to remember this does not work. The first idea that comes to my mind is to use Bash for loop. But wait, what is the cause of this? The man page reveals it in it's full glory.

UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send

bug reports using; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).

When shell expands the asterisk, unzip treats everything from the second parameters as files within the archive. The unzip itself is able to do globs. No offense aginst Info-ZIP guys who do a really great job, but this is cool. So you have to be faster here:

# unzip \*zip

Then it works.

We are ofter surprised when programs in UNIX or Linux misbehave, but nothing is perfect.
12 August 2011 | bash | zip