globbing is
turned on). To extract all FORTRAN and C source files, regardless of
case (e.g., both *.c and *.C, and any makefile, Makefile, MAKEFILE or
similar):
unzip -C source.zip "*.[fch]" makefile ‐d /tmp
To extract any such files but convert any uppercase MS‐DOS or VMS names
to lowercase and convert the line‐endings of all of the files to the lo‐
cal standard (without respect to any files that might be marked ‘‘bi‐
nary’’):
unzip -aaCL source.zip "*.[fch]" makefile ‐d /tmp
To extract only newer versions of the files already in the current di‐
rectory, without querying (NOTE: be careful of unzipping in one time‐
zone a zipfile created in another‐‐ZIP archives other than those created
by Zip 2.1 or later contain no timezone information, and a ‘‘newer’’
file from an eastern timezone may, in fact, be older):
unzip -fo sources
To extract newer versions of the files already in the current directory
and to create any files not already there (same caveat as previous exam‐
ple):
unzip -uo sources
To display a diagnostic screen showing which unzip and zipinfo options
are stored in environment variables, whether decryption support was com‐
piled in, the compiler with which unzip was compiled, etc.:
unzip -v
In the last five examples, assume that UNZIP or UNZIP_OPTS is set to ‐q.
To do a singly quiet listing:
unzip -l file.zip
To do a doubly quiet listing:
unzip -ql file.zip
(Note that the ‘‘.zip’’ is generally not necessary.) To do a standard
listing:
unzip --ql file.zip
or
unzip -l-q file.zip
or
unzip -l--q file.zip
(Extra minuses in options don’t hurt.)
TIPS
The current maintainer, being a lazy sort, finds it very useful to de‐
fine a pair of aliases: tt for ‘‘unzip -tq’’ and ii for ‘‘unzip -Z’’
(or ‘‘zipinfo’’). One may then simply type ‘‘tt zipfile’’ to test an
archive, something that is worth making a habit of doing. With luck un‐
zip will report ‘‘No errors detected in compressed data of zip‐
file.zip,’’ after which one may breathe a sigh of relief.
The maintainer also finds it useful to set the UNZIP environment vari‐
able to ‘‘-aL’’ and is tempted to add ‘‘-C’’ as well. His ZIPINFO vari‐
able is set to ‘‘-z’’.
DIAGNOSTICS
The exit status (or error level) approximates the exit codes defined by
PKWARE and takes on the following values, except under VMS:
0 normal; no errors or warnings detected.
1 one or more warning errors were encountered, but process‐
ing completed successfully anyway. This includes zipfiles
where one or more files was skipped due to unsupported
compression method or encryption with an unknown password.
2 a generic error in the zipfile format was detected. Pro‐
cessing may have completed successfully anyway; some bro‐
ken zipfiles created by other archivers have simple work‐
arounds.
3 a severe error in the zipfile format was detected. Pro‐
cessing probably failed immediately.
4 unzip was unable to allocate memory for one or more
buffers during program initialization.
5 unzip was unable to allocate memory or unable to obtain a
tty to read the decryption password(s).
6 unzip was unable to allocate memory during decompression
to disk.
7 unzip was unable to allocate memory during in‐memory de‐
compression.