1UNZIP(1L) UNZIP(1L)
2
3
4
6 unzip - list, test and extract compressed files in a ZIP archive
7
9 unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) ...]
10 [-x xfile(s) ...] [-d exdir]
11
13 unzip will list, test, or extract files from a ZIP archive, commonly
14 found on MS-DOS systems. The default behavior (with no options) is to
15 extract into the current directory (and subdirectories below it) all
16 files from the specified ZIP archive. A companion program, zip(1L),
17 creates ZIP archives; both programs are compatible with archives cre‐
18 ated by PKWARE's PKZIP and PKUNZIP for MS-DOS, but in many cases the
19 program options or default behaviors differ.
20
22 file[.zip]
23 Path of the ZIP archive(s). If the file specification is a
24 wildcard, each matching file is processed in an order determined
25 by the operating system (or file system). Only the filename can
26 be a wildcard; the path itself cannot. Wildcard expressions are
27 similar to those supported in commonly used Unix shells (sh,
28 ksh, csh) and may contain:
29
30 * matches a sequence of 0 or more characters
31
32 ? matches exactly 1 character
33
34 [...] matches any single character found inside the brackets;
35 ranges are specified by a beginning character, a hyphen,
36 and an ending character. If an exclamation point or a
37 caret (`!' or `^') follows the left bracket, then the
38 range of characters within the brackets is complemented
39 (that is, anything except the characters inside the
40 brackets is considered a match). To specify a verbatim
41 left bracket, the three-character sequence ``[[]'' has to
42 be used.
43
44 (Be sure to quote any character that might otherwise be inter‐
45 preted or modified by the operating system, particularly under
46 Unix and VMS.) If no matches are found, the specification is
47 assumed to be a literal filename; and if that also fails, the
48 suffix .zip is appended. Note that self-extracting ZIP files
49 are supported, as with any other ZIP archive; just specify the
50 .exe suffix (if any) explicitly.
51
52 [file(s)]
53 An optional list of archive members to be processed, separated
54 by spaces. (VMS versions compiled with VMSCLI defined must de‐
55 limit files with commas instead. See -v in OPTIONS below.)
56 Regular expressions (wildcards) may be used to match multiple
57 members; see above. Again, be sure to quote expressions that
58 would otherwise be expanded or modified by the operating system.
59
60 [-x xfile(s)]
61 An optional list of archive members to be excluded from process‐
62 ing. Since wildcard characters normally match (`/') directory
63 separators (for exceptions see the option -W), this option may
64 be used to exclude any files that are in subdirectories. For
65 example, ``unzip foo *.[ch] -x */*'' would extract all C source
66 files in the main directory, but none in any subdirectories.
67 Without the -x option, all C source files in all directories
68 within the zipfile would be extracted.
69
70 [-d exdir]
71 An optional directory to which to extract files. By default,
72 all files and subdirectories are recreated in the current direc‐
73 tory; the -d option allows extraction in an arbitrary directory
74 (always assuming one has permission to write to the directory).
75 This option need not appear at the end of the command line; it
76 is also accepted before the zipfile specification (with the nor‐
77 mal options), immediately after the zipfile specification, or
78 between the file(s) and the -x option. The option and directory
79 may be concatenated without any white space between them, but
80 note that this may cause normal shell behavior to be suppressed.
81 In particular, ``-d ~'' (tilde) is expanded by Unix C shells
82 into the name of the user's home directory, but ``-d~'' is
83 treated as a literal subdirectory ``~'' of the current direc‐
84 tory.
85
87 Note that, in order to support obsolescent hardware, unzip's usage
88 screen is limited to 22 or 23 lines and should therefore be considered
89 only a reminder of the basic unzip syntax rather than an exhaustive
90 list of all possible flags. The exhaustive list follows:
91
92 -Z [22mzipinfo(1L) mode. If the first option on the command line is
93 -Z, the remaining options are taken to be zipinfo(1L) options.
94 See the appropriate manual page for a description of these op‐
95 tions.
96
97 -A [OS/2, Unix DLL] print extended help for the DLL's programming
98 interface (API).
99
100 -c extract files to stdout/screen (``CRT''). This option is simi‐
101 lar to the -p option except that the name of each file is
102 printed as it is extracted, the -a option is allowed, and ASCII-
103 EBCDIC conversion is automatically performed if appropriate.
104 This option is not listed in the unzip usage screen.
105
106 -f freshen existing files, i.e., extract only those files that al‐
107 ready exist on disk and that are newer than the disk copies. By
108 default unzip queries before overwriting, but the -o option may
109 be used to suppress the queries. Note that under many operating
110 systems, the TZ (timezone) environment variable must be set cor‐
111 rectly in order for -f and -u to work properly (under Unix the
112 variable is usually set automatically). The reasons for this
113 are somewhat subtle but have to do with the differences between
114 DOS-format file times (always local time) and Unix-format times
115 (always in GMT/UTC) and the necessity to compare the two. A
116 typical TZ value is ``PST8PDT'' (US Pacific time with automatic
117 adjustment for Daylight Savings Time or ``summer time'').
118
119 -l list archive files (short format). The names, uncompressed file
120 sizes and modification dates and times of the specified files
121 are printed, along with totals for all files specified. If Un‐
122 Zip was compiled with OS2_EAS defined, the -l option also lists
123 columns for the sizes of stored OS/2 extended attributes (EAs)
124 and OS/2 access control lists (ACLs). In addition, the zipfile
125 comment and individual file comments (if any) are displayed. If
126 a file was archived from a single-case file system (for example,
127 the old MS-DOS FAT file system) and the -L option was given, the
128 filename is converted to lowercase and is prefixed with a caret
129 (^).
130
131 -p extract files to pipe (stdout). Nothing but the file data is
132 sent to stdout, and the files are always extracted in binary
133 format, just as they are stored (no conversions).
134
135 -t test archive files. This option extracts each specified file in
136 memory and compares the CRC (cyclic redundancy check, an en‐
137 hanced checksum) of the expanded file with the original file's
138 stored CRC value.
139
140 -T [most OSes] set the timestamp on the archive(s) to that of the
141 newest file in each one. This corresponds to zip's -go option
142 except that it can be used on wildcard zipfiles (e.g., ``unzip
143 -T \*.zip'') and is much faster.
144
145 -u update existing files and create new ones if needed. This op‐
146 tion performs the same function as the -f option, extracting
147 (with query) files that are newer than those with the same name
148 on disk, and in addition it extracts those files that do not al‐
149 ready exist on disk. See -f above for information on setting
150 the timezone properly.
151
152 -v list archive files (verbose format) or show diagnostic version
153 info. This option has evolved and now behaves as both an option
154 and a modifier. As an option it has two purposes: when a zip‐
155 file is specified with no other options, -v lists archive files
156 verbosely, adding to the basic -l info the compression method,
157 compressed size, compression ratio and 32-bit CRC. In contrast
158 to most of the competing utilities, unzip removes the 12 addi‐
159 tional header bytes of encrypted entries from the compressed
160 size numbers. Therefore, compressed size and compression ratio
161 figures are independent of the entry's encryption status and
162 show the correct compression performance. (The complete size of
163 the encrypted compressed data stream for zipfile entries is re‐
164 ported by the more verbose zipinfo(1L) reports, see the separate
165 manual.) When no zipfile is specified (that is, the complete
166 command is simply ``unzip -v''), a diagnostic screen is printed.
167 In addition to the normal header with release date and version,
168 unzip lists the home Info-ZIP ftp site and where to find a list
169 of other ftp and non-ftp sites; the target operating system for
170 which it was compiled, as well as (possibly) the hardware on
171 which it was compiled, the compiler and version used, and the
172 compilation date; any special compilation options that might af‐
173 fect the program's operation (see also DECRYPTION below); and
174 any options stored in environment variables that might do the
175 same (see ENVIRONMENT OPTIONS below). As a modifier it works in
176 conjunction with other options (e.g., -t) to produce more ver‐
177 bose or debugging output; this is not yet fully implemented but
178 will be in future releases.
179
180 -z display only the archive comment.
181
183 -a convert text files. Ordinarily all files are extracted exactly
184 as they are stored (as ``binary'' files). The -a option causes
185 files identified by zip as text files (those with the `t' label
186 in zipinfo listings, rather than `b') to be automatically ex‐
187 tracted as such, converting line endings, end-of-file characters
188 and the character set itself as necessary. (For example, Unix
189 files use line feeds (LFs) for end-of-line (EOL) and have no
190 end-of-file (EOF) marker; Macintoshes use carriage returns (CRs)
191 for EOLs; and most PC operating systems use CR+LF for EOLs and
192 control-Z for EOF. In addition, IBM mainframes and the Michigan
193 Terminal System use EBCDIC rather than the more common ASCII
194 character set, and NT supports Unicode.) Note that zip's iden‐
195 tification of text files is by no means perfect; some ``text''
196 files may actually be binary and vice versa. unzip therefore
197 prints ``[text]'' or ``[binary]'' as a visual check for each
198 file it extracts when using the -a option. The -aa option
199 forces all files to be extracted as text, regardless of the sup‐
200 posed file type. On VMS, see also -S.
201
202 -b [general] treat all files as binary (no text conversions). This
203 is a shortcut for ---a.
204
205 -b [Tandem] force the creation files with filecode type 180 ('C')
206 when extracting Zip entries marked as "text". (On Tandem, -a is
207 enabled by default, see above).
208
209 -b [VMS] auto-convert binary files (see -a above) to fixed-length,
210 512-byte record format. Doubling the option (-bb) forces all
211 files to be extracted in this format. When extracting to stan‐
212 dard output (-c or -p option in effect), the default conversion
213 of text record delimiters is disabled for binary (-b) resp. all
214 (-bb) files.
215
216 -B [when compiled with UNIXBACKUP defined] save a backup copy of
217 each overwritten file. The backup file is gets the name of the
218 target file with a tilde and optionally a unique sequence number
219 (up to 5 digits) appended. The sequence number is applied when‐
220 ever another file with the original name plus tilde already ex‐
221 ists. When used together with the "overwrite all" option -o,
222 numbered backup files are never created. In this case, all
223 backup files are named as the original file with an appended
224 tilde, existing backup files are deleted without notice. This
225 feature works similarly to the default behavior of emacs(1) in
226 many locations.
227
228 Example: the old copy of ``foo'' is renamed to ``foo~''.
229
230 Warning: Users should be aware that the -B option does not pre‐
231 vent loss of existing data under all circumstances. For exam‐
232 ple, when unzip is run in overwrite-all mode, an existing
233 ``foo~'' file is deleted before unzip attempts to rename ``foo''
234 to ``foo~''. When this rename attempt fails (because of a file
235 locks, insufficient privileges, or ...), the extraction of
236 ``foo~'' gets cancelled, but the old backup file is already
237 lost. A similar scenario takes place when the sequence number
238 range for numbered backup files gets exhausted (99999, or 65535
239 for 16-bit systems). In this case, the backup file with the
240 maximum sequence number is deleted and replaced by the new
241 backup version without notice.
242
243 -C use case-insensitive matching for the selection of archive en‐
244 tries from the command-line list of extract selection patterns.
245 unzip's philosophy is ``you get what you ask for'' (this is also
246 responsible for the -L/-U change; see the relevant options be‐
247 low). Because some file systems are fully case-sensitive (no‐
248 tably those under the Unix operating system) and because both
249 ZIP archives and unzip itself are portable across platforms, un‐
250 zip's default behavior is to match both wildcard and literal
251 filenames case-sensitively. That is, specifying ``makefile'' on
252 the command line will only match ``makefile'' in the archive,
253 not ``Makefile'' or ``MAKEFILE'' (and similarly for wildcard
254 specifications). Since this does not correspond to the behavior
255 of many other operating/file systems (for example, OS/2 HPFS,
256 which preserves mixed case but is not sensitive to it), the -C
257 option may be used to force all filename matches to be case-in‐
258 sensitive. In the example above, all three files would then
259 match ``makefile'' (or ``make*'', or similar). The -C option
260 affects file specs in both the normal file list and the ex‐
261 cluded-file list (xlist).
262
263 Please note that the -C option does neither affect the search
264 for the zipfile(s) nor the matching of archive entries to exist‐
265 ing files on the extraction path. On a case-sensitive file sys‐
266 tem, unzip will never try to overwrite a file ``FOO'' when ex‐
267 tracting an entry ``foo''!
268
269 -D skip restoration of timestamps for extracted items. Normally,
270 unzip tries to restore all meta-information for extracted items
271 that are supplied in the Zip archive (and do not require privi‐
272 leges or impose a security risk). By specifying -D, unzip is
273 told to suppress restoration of timestamps for directories ex‐
274 plicitly created from Zip archive entries. This option only ap‐
275 plies to ports that support setting timestamps for directories
276 (currently ATheOS, BeOS, MacOS, OS/2, Unix, VMS, Win32, for
277 other unzip ports, -D has no effect). The duplicated option -DD
278 forces suppression of timestamp restoration for all extracted
279 entries (files and directories). This option results in setting
280 the timestamps for all extracted entries to the current time.
281
282 On VMS, the default setting for this option is -D for consis‐
283 tency with the behaviour of BACKUP: file timestamps are re‐
284 stored, timestamps of extracted directories are left at the cur‐
285 rent time. To enable restoration of directory timestamps, the
286 negated option --D should be specified. On VMS, the option -D
287 disables timestamp restoration for all extracted Zip archive
288 items. (Here, a single -D on the command line combines with the
289 default -D to do what an explicit -DD does on other systems.)
290
291 -E [MacOS only] display contents of MacOS extra field during re‐
292 store operation.
293
294 -F [Acorn only] suppress removal of NFS filetype extension from
295 stored filenames.
296
297 -F [non-Acorn systems supporting long filenames with embedded com‐
298 mas, and only if compiled with ACORN_FTYPE_NFS defined] trans‐
299 late filetype information from ACORN RISC OS extra field blocks
300 into a NFS filetype extension and append it to the names of the
301 extracted files. (When the stored filename appears to already
302 have an appended NFS filetype extension, it is replaced by the
303 info from the extra field.)
304
305 -i [MacOS only] ignore filenames stored in MacOS extra fields. In‐
306 stead, the most compatible filename stored in the generic part
307 of the entry's header is used.
308
309 -j junk paths. The archive's directory structure is not recreated;
310 all files are deposited in the extraction directory (by default,
311 the current one).
312
313 -J [BeOS only] junk file attributes. The file's BeOS file at‐
314 tributes are not restored, just the file's data.
315
316 -J [MacOS only] ignore MacOS extra fields. All Macintosh specific
317 info is skipped. Data-fork and resource-fork are restored as
318 separate files.
319
320 -K [AtheOS, BeOS, Unix only] retain SUID/SGID/Tacky file at‐
321 tributes. Without this flag, these attribute bits are cleared
322 for security reasons.
323
324 -L convert to lowercase any filename originating on an uppercase-
325 only operating system or file system. (This was unzip's default
326 behavior in releases prior to 5.11; the new default behavior is
327 identical to the old behavior with the -U option, which is now
328 obsolete and will be removed in a future release.) Depending on
329 the archiver, files archived under single-case file systems
330 (VMS, old MS-DOS FAT, etc.) may be stored as all-uppercase
331 names; this can be ugly or inconvenient when extracting to a
332 case-preserving file system such as OS/2 HPFS or a case-sensi‐
333 tive one such as under Unix. By default unzip lists and ex‐
334 tracts such filenames exactly as they're stored (excepting trun‐
335 cation, conversion of unsupported characters, etc.); this option
336 causes the names of all files from certain systems to be con‐
337 verted to lowercase. The -LL option forces conversion of every
338 filename to lowercase, regardless of the originating file sys‐
339 tem.
340
341 -M pipe all output through an internal pager similar to the Unix
342 more(1) command. At the end of a screenful of output, unzip
343 pauses with a ``--More--'' prompt; the next screenful may be
344 viewed by pressing the Enter (Return) key or the space bar. un‐
345 zip can be terminated by pressing the ``q'' key and, on some
346 systems, the Enter/Return key. Unlike Unix more(1), there is no
347 forward-searching or editing capability. Also, unzip doesn't
348 notice if long lines wrap at the edge of the screen, effectively
349 resulting in the printing of two or more lines and the likeli‐
350 hood that some text will scroll off the top of the screen before
351 being viewed. On some systems the number of available lines on
352 the screen is not detected, in which case unzip assumes the
353 height is 24 lines.
354
355 -n never overwrite existing files. If a file already exists, skip
356 the extraction of that file without prompting. By default unzip
357 queries before extracting any file that already exists; the user
358 may choose to overwrite only the current file, overwrite all
359 files, skip extraction of the current file, skip extraction of
360 all existing files, or rename the current file.
361
362 -N [Amiga] extract file comments as Amiga filenotes. File comments
363 are created with the -c option of zip(1L), or with the -N option
364 of the Amiga port of zip(1L), which stores filenotes as com‐
365 ments.
366
367 -o overwrite existing files without prompting. This is a dangerous
368 option, so use it with care. (It is often used with -f, how‐
369 ever, and is the only way to overwrite directory EAs under
370 OS/2.)
371
372 -P password
373 use password to decrypt encrypted zipfile entries (if any).
374 THIS IS INSECURE! Many multi-user operating systems provide
375 ways for any user to see the current command line of any other
376 user; even on stand-alone systems there is always the threat of
377 over-the-shoulder peeking. Storing the plaintext password as
378 part of a command line in an automated script is even worse.
379 Whenever possible, use the non-echoing, interactive prompt to
380 enter passwords. (And where security is truly important, use
381 strong encryption such as Pretty Good Privacy instead of the
382 relatively weak encryption provided by standard zipfile utili‐
383 ties.)
384
385 -q perform operations quietly (-qq = even quieter). Ordinarily un‐
386 zip prints the names of the files it's extracting or testing,
387 the extraction methods, any file or zipfile comments that may be
388 stored in the archive, and possibly a summary when finished with
389 each archive. The -q[q] options suppress the printing of some
390 or all of these messages.
391
392 -s [OS/2, NT, MS-DOS] convert spaces in filenames to underscores.
393 Since all PC operating systems allow spaces in filenames, unzip
394 by default extracts filenames with spaces intact (e.g.,
395 ``EA DATA. SF''). This can be awkward, however, since MS-DOS in
396 particular does not gracefully support spaces in filenames.
397 Conversion of spaces to underscores can eliminate the awkward‐
398 ness in some cases.
399
400 -S [VMS] convert text files (-a, -aa) into Stream_LF record format,
401 instead of the text-file default, variable-length record format.
402 (Stream_LF is the default record format of VMS unzip. It is ap‐
403 plied unless conversion (-a, -aa and/or -b, -bb) is requested or
404 a VMS-specific entry is processed.)
405
406 -U [UNICODE_SUPPORT only] modify or disable UTF-8 handling. When
407 UNICODE_SUPPORT is available, the option -U forces unzip to es‐
408 cape all non-ASCII characters from UTF-8 coded filenames as
409 ``#Uxxxx'' (for UCS-2 characters, or ``#Lxxxxxx'' for unicode
410 codepoints needing 3 octets). This option is mainly provided
411 for debugging purpose when the fairly new UTF-8 support is sus‐
412 pected to mangle up extracted filenames.
413
414 The option -UU allows to entirely disable the recognition of
415 UTF-8 encoded filenames. The handling of filename codings
416 within unzip falls back to the behaviour of previous versions.
417
418 [old, obsolete usage] leave filenames uppercase if created under
419 MS-DOS, VMS, etc. See -L above.
420
421 -V retain (VMS) file version numbers. VMS files can be stored with
422 a version number, in the format file.ext;##. By default the
423 ``;##'' version numbers are stripped, but this option allows
424 them to be retained. (On file systems that limit filenames to
425 particularly short lengths, the version numbers may be truncated
426 or stripped regardless of this option.)
427
428 -W [only when WILD_STOP_AT_DIR compile-time option enabled] modi‐
429 fies the pattern matching routine so that both `?' (single-char
430 wildcard) and `*' (multi-char wildcard) do not match the direc‐
431 tory separator character `/'. (The two-character sequence
432 ``**'' acts as a multi-char wildcard that includes the directory
433 separator in its matched characters.) Examples:
434
435 "*.c" matches "foo.c" but not "mydir/foo.c"
436 "**.c" matches both "foo.c" and "mydir/foo.c"
437 "*/*.c" matches "bar/foo.c" but not "baz/bar/foo.c"
438 "??*/*" matches "ab/foo" and "abc/foo"
439 but not "a/foo" or "a/b/foo"
440
441 This modified behaviour is equivalent to the pattern matching
442 style used by the shells of some of UnZip's supported target OSs
443 (one example is Acorn RISC OS). This option may not be avail‐
444 able on systems where the Zip archive's internal directory sepa‐
445 rator character `/' is allowed as regular character in native
446 operating system filenames. (Currently, UnZip uses the same
447 pattern matching rules for both wildcard zipfile specifications
448 and zip entry selection patterns in most ports. For systems al‐
449 lowing `/' as regular filename character, the -W option would
450 not work as expected on a wildcard zipfile specification.)
451
452 -X [VMS, Unix, OS/2, NT, Tandem] restore owner/protection info
453 (UICs and ACL entries) under VMS, or user and group info
454 (UID/GID) under Unix, or access control lists (ACLs) under cer‐
455 tain network-enabled versions of OS/2 (Warp Server with IBM LAN
456 Server/Requester 3.0 to 5.0; Warp Connect with IBM Peer 1.0), or
457 security ACLs under Windows NT. In most cases this will require
458 special system privileges, and doubling the option (-XX) under
459 NT instructs unzip to use privileges for extraction; but under
460 Unix, for example, a user who belongs to several groups can re‐
461 store files owned by any of those groups, as long as the user
462 IDs match his or her own. Note that ordinary file attributes
463 are always restored--this option applies only to optional, extra
464 ownership info available on some operating systems. [NT's ac‐
465 cess control lists do not appear to be especially compatible
466 with OS/2's, so no attempt is made at cross-platform portability
467 of access privileges. It is not clear under what conditions
468 this would ever be useful anyway.]
469
470 -Y [VMS] treat archived file name endings of ``.nnn'' (where
471 ``nnn'' is a decimal number) as if they were VMS version num‐
472 bers (``;nnn''). (The default is to treat them as file types.)
473 Example:
474 "a.b.3" -> "a.b;3".
475
476 -$ [MS-DOS, OS/2, NT] restore the volume label if the extraction
477 medium is removable (e.g., a diskette). Doubling the option
478 (-$$) allows fixed media (hard disks) to be labeled as well. By
479 default, volume labels are ignored.
480
481 -/ extensions
482 [Acorn only] overrides the extension list supplied by Unzip$Ext
483 environment variable. During extraction, filename extensions
484 that match one of the items in this extension list are swapped
485 in front of the base name of the extracted file.
486
487 -: [all but Acorn, VM/CMS, MVS, Tandem] allows to extract archive
488 members into locations outside of the current `` extraction root
489 folder''. For security reasons, unzip normally removes ``parent
490 dir'' path components (``../'') from the names of extracted
491 file. This safety feature (new for version 5.50) prevents unzip
492 from accidentally writing files to ``sensitive'' areas outside
493 the active extraction folder tree head. The -: option lets un‐
494 zip switch back to its previous, more liberal behaviour, to al‐
495 low exact extraction of (older) archives that used ``../'' com‐
496 ponents to create multiple directory trees at the level of the
497 current extraction folder. This option does not enable writing
498 explicitly to the root directory (``/''). To achieve this, it
499 is necessary to set the extraction target folder to root (e.g.
500 -d / ). However, when the -: option is specified, it is still
501 possible to implicitly write to the root directory by specifying
502 enough ``../'' path components within the zip archive. Use this
503 option with extreme caution.
504
505 -^ [Unix only] allow control characters in names of extracted ZIP
506 archive entries. On Unix, a file name may contain any (8-bit)
507 character code with the two exception '/' (directory delimiter)
508 and NUL (0x00, the C string termination indicator), unless the
509 specific file system has more restrictive conventions. Gener‐
510 ally, this allows to embed ASCII control characters (or even so‐
511 phisticated control sequences) in file names, at least on 'na‐
512 tive' Unix file systems. However, it may be highly suspicious
513 to make use of this Unix "feature". Embedded control characters
514 in file names might have nasty side effects when displayed on
515 screen by some listing code without sufficient filtering. And,
516 for ordinary users, it may be difficult to handle such file
517 names (e.g. when trying to specify it for open, copy, move, or
518 delete operations). Therefore, unzip applies a filter by de‐
519 fault that removes potentially dangerous control characters from
520 the extracted file names. The -^ option allows to override this
521 filter in the rare case that embedded filename control charac‐
522 ters are to be intentionally restored.
523
524 -2 [VMS] force unconditionally conversion of file names to
525 ODS2-compatible names. The default is to exploit the destina‐
526 tion file system, preserving case and extended file name charac‐
527 ters on an ODS5 destination file system; and applying the
528 ODS2-compatibility file name filtering on an ODS2 destination
529 file system.
530
532 unzip's default behavior may be modified via options placed in an envi‐
533 ronment variable. This can be done with any option, but it is probably
534 most useful with the -a, -L, -C, -q, -o, or -n modifiers: make unzip
535 auto-convert text files by default, make it convert filenames from up‐
536 percase systems to lowercase, make it match names case-insensitively,
537 make it quieter, or make it always overwrite or never overwrite files
538 as it extracts them. For example, to make unzip act as quietly as pos‐
539 sible, only reporting errors, one would use one of the following com‐
540 mands:
541
542 Unix Bourne shell:
543 UNZIP=-qq; export UNZIP
544
545 Unix C shell:
546 setenv UNZIP -qq
547
548 OS/2 or MS-DOS:
549 set UNZIP=-qq
550
551 VMS (quotes for lowercase):
552 define UNZIP_OPTS "-qq"
553
554 Environment options are, in effect, considered to be just like any
555 other command-line options, except that they are effectively the first
556 options on the command line. To override an environment option, one
557 may use the ``minus operator'' to remove it. For instance, to override
558 one of the quiet-flags in the example above, use the command
559
560 unzip --q[other options] zipfile
561
562 The first hyphen is the normal switch character, and the second is a
563 minus sign, acting on the q option. Thus the effect here is to cancel
564 one quantum of quietness. To cancel both quiet flags, two (or more)
565 minuses may be used:
566
567 unzip -t--q zipfile
568 unzip ---qt zipfile
569
570 (the two are equivalent). This may seem awkward or confusing, but it
571 is reasonably intuitive: just ignore the first hyphen and go from
572 there. It is also consistent with the behavior of Unix nice(1).
573
574 As suggested by the examples above, the default variable names are UN‐
575 ZIP_OPTS for VMS (where the symbol used to install unzip as a foreign
576 command would otherwise be confused with the environment variable), and
577 UNZIP for all other operating systems. For compatibility with zip(1L),
578 UNZIPOPT is also accepted (don't ask). If both UNZIP and UNZIPOPT are
579 defined, however, UNZIP takes precedence. unzip's diagnostic option
580 (-v with no zipfile name) can be used to check the values of all four
581 possible unzip and zipinfo environment variables.
582
583 The timezone variable (TZ) should be set according to the local time‐
584 zone in order for the -f and -u to operate correctly. See the descrip‐
585 tion of -f above for details. This variable may also be necessary to
586 get timestamps of extracted files to be set correctly. The WIN32
587 (Win9x/ME/NT4/2K/XP/2K3) port of unzip gets the timezone configuration
588 from the registry, assuming it is correctly set in the Control Panel.
589 The TZ variable is ignored for this port.
590
592 Encrypted archives are fully supported by Info-ZIP software, but due to
593 United States export restrictions, de-/encryption support might be dis‐
594 abled in your compiled binary. However, since spring 2000, US export
595 restrictions have been liberated, and our source archives do now in‐
596 clude full crypt code. In case you need binary distributions with
597 crypt support enabled, see the file ``WHERE'' in any Info-ZIP source or
598 binary distribution for locations both inside and outside the US.
599
600 Some compiled versions of unzip may not support decryption. To check a
601 version for crypt support, either attempt to test or extract an en‐
602 crypted archive, or else check unzip's diagnostic screen (see the -v
603 option above) for ``[decryption]'' as one of the special compilation
604 options.
605
606 As noted above, the -P option may be used to supply a password on the
607 command line, but at a cost in security. The preferred decryption
608 method is simply to extract normally; if a zipfile member is encrypted,
609 unzip will prompt for the password without echoing what is typed. un‐
610 zip continues to use the same password as long as it appears to be
611 valid, by testing a 12-byte header on each file. The correct password
612 will always check out against the header, but there is a 1-in-256
613 chance that an incorrect password will as well. (This is a security
614 feature of the PKWARE zipfile format; it helps prevent brute-force at‐
615 tacks that might otherwise gain a large speed advantage by testing only
616 the header.) In the case that an incorrect password is given but it
617 passes the header test anyway, either an incorrect CRC will be gener‐
618 ated for the extracted data or else unzip will fail during the extrac‐
619 tion because the ``decrypted'' bytes do not constitute a valid com‐
620 pressed data stream.
621
622 If the first password fails the header check on some file, unzip will
623 prompt for another password, and so on until all files are extracted.
624 If a password is not known, entering a null password (that is, just a
625 carriage return or ``Enter'') is taken as a signal to skip all further
626 prompting. Only unencrypted files in the archive(s) will thereafter be
627 extracted. (In fact, that's not quite true; older versions of zip(1L)
628 and zipcloak(1L) allowed null passwords, so unzip checks each encrypted
629 file to see if the null password works. This may result in ``false
630 positives'' and extraction errors, as noted above.)
631
632 Archives encrypted with 8-bit passwords (for example, passwords with
633 accented European characters) may not be portable across systems and/or
634 other archivers. This problem stems from the use of multiple encoding
635 methods for such characters, including Latin-1 (ISO 8859-1) and OEM
636 code page 850. DOS PKZIP 2.04g uses the OEM code page; Windows PKZIP
637 2.50 uses Latin-1 (and is therefore incompatible with DOS PKZIP); Info-
638 ZIP uses the OEM code page on DOS, OS/2 and Win3.x ports but ISO coding
639 (Latin-1 etc.) everywhere else; and Nico Mak's WinZip 6.x does not al‐
640 low 8-bit passwords at all. UnZip 5.3 (or newer) attempts to use the
641 default character set first (e.g., Latin-1), followed by the alternate
642 one (e.g., OEM code page) to test passwords. On EBCDIC systems, if
643 both of these fail, EBCDIC encoding will be tested as a last resort.
644 (EBCDIC is not tested on non-EBCDIC systems, because there are no known
645 archivers that encrypt using EBCDIC encoding.) ISO character encodings
646 other than Latin-1 are not supported. The new addition of (partially)
647 Unicode (resp. UTF-8) support in UnZip 6.0 has not yet been adapted to
648 the encryption password handling in unzip. On systems that use UTF-8
649 as native character encoding, unzip simply tries decryption with the
650 native UTF-8 encoded password; the built-in attempts to check the pass‐
651 word in translated encoding have not yet been adapted for UTF-8 support
652 and will consequently fail.
653
655 To use unzip to extract all members of the archive letters.zip into the
656 current directory and subdirectories below it, creating any subdirecto‐
657 ries as necessary:
658
659 unzip letters
660
661 To extract all members of letters.zip into the current directory only:
662
663 unzip -j letters
664
665 To test letters.zip, printing only a summary message indicating whether
666 the archive is OK or not:
667
668 unzip -tq letters
669
670 To test all zipfiles in the current directory, printing only the sum‐
671 maries:
672
673 unzip -tq \*.zip
674
675 (The backslash before the asterisk is only required if the shell ex‐
676 pands wildcards, as in Unix; double quotes could have been used in‐
677 stead, as in the source examples below.) To extract to standard output
678 all members of letters.zip whose names end in .tex, auto-converting to
679 the local end-of-line convention and piping the output into more(1):
680
681 unzip -ca letters \*.tex | more
682
683 To extract the binary file paper1.dvi to standard output and pipe it to
684 a printing program:
685
686 unzip -p articles paper1.dvi | dvips
687
688 To extract all FORTRAN and C source files--*.f, *.c, *.h, and Make‐
689 file--into the /tmp directory:
690
691 unzip source.zip "*.[fch]" Makefile -d /tmp
692
693 (the double quotes are necessary only in Unix and only if globbing is
694 turned on). To extract all FORTRAN and C source files, regardless of
695 case (e.g., both *.c and *.C, and any makefile, Makefile, MAKEFILE or
696 similar):
697
698 unzip -C source.zip "*.[fch]" makefile -d /tmp
699
700 To extract any such files but convert any uppercase MS-DOS or VMS names
701 to lowercase and convert the line-endings of all of the files to the
702 local standard (without respect to any files that might be marked ``bi‐
703 nary''):
704
705 unzip -aaCL source.zip "*.[fch]" makefile -d /tmp
706
707 To extract only newer versions of the files already in the current di‐
708 rectory, without querying (NOTE: be careful of unzipping in one time‐
709 zone a zipfile created in another--ZIP archives other than those cre‐
710 ated by Zip 2.1 or later contain no timezone information, and a
711 ``newer'' file from an eastern timezone may, in fact, be older):
712
713 unzip -fo sources
714
715 To extract newer versions of the files already in the current directory
716 and to create any files not already there (same caveat as previous ex‐
717 ample):
718
719 unzip -uo sources
720
721 To display a diagnostic screen showing which unzip and zipinfo options
722 are stored in environment variables, whether decryption support was
723 compiled in, the compiler with which unzip was compiled, etc.:
724
725 unzip -v
726
727 In the last five examples, assume that UNZIP or UNZIP_OPTS is set to
728 -q. To do a singly quiet listing:
729
730 unzip -l file.zip
731
732 To do a doubly quiet listing:
733
734 unzip -ql file.zip
735
736 (Note that the ``.zip'' is generally not necessary.) To do a standard
737 listing:
738
739 unzip --ql file.zip
740 or
741 unzip -l-q file.zip
742 or
743 unzip -l--q file.zip
744 (Extra minuses in options don't hurt.)
745
747 The current maintainer, being a lazy sort, finds it very useful to de‐
748 fine a pair of aliases: tt for ``unzip -tq'' and ii for ``unzip -Z''
749 (or ``zipinfo''). One may then simply type ``tt zipfile'' to test an
750 archive, something that is worth making a habit of doing. With luck
751 unzip will report ``No errors detected in compressed data of zip‐
752 file.zip,'' after which one may breathe a sigh of relief.
753
754 The maintainer also finds it useful to set the UNZIP environment vari‐
755 able to ``-aL'' and is tempted to add ``-C'' as well. His ZIPINFO
756 variable is set to ``-z''.
757
759 The exit status (or error level) approximates the exit codes defined by
760 PKWARE and takes on the following values, except under VMS:
761
762 0 normal; no errors or warnings detected.
763
764 1 one or more warning errors were encountered, but process‐
765 ing completed successfully anyway. This includes zip‐
766 files where one or more files was skipped due to unsup‐
767 ported compression method or encryption with an unknown
768 password.
769
770 2 a generic error in the zipfile format was detected. Pro‐
771 cessing may have completed successfully anyway; some bro‐
772 ken zipfiles created by other archivers have simple work-
773 arounds.
774
775 3 a severe error in the zipfile format was detected. Pro‐
776 cessing probably failed immediately.
777
778 4 unzip was unable to allocate memory for one or more buf‐
779 fers during program initialization.
780
781 5 unzip was unable to allocate memory or unable to obtain a
782 tty to read the decryption password(s).
783
784 6 unzip was unable to allocate memory during decompression
785 to disk.
786
787 7 unzip was unable to allocate memory during in-memory de‐
788 compression.
789
790 8 [currently not used]
791
792 9 the specified zipfiles were not found.
793
794 10 invalid options were specified on the command line.
795
796 11 no matching files were found.
797
798 12 invalid zip file with overlapped components (possible
799 zip-bomb). The zip-bomb checks can be disabled by using
800 the UNZIP_DISABLE_ZIPBOMB_DETECTION=TRUE environment
801 variable.
802
803 50 the disk is (or was) full during extraction.
804
805 51 the end of the ZIP archive was encountered prematurely.
806
807 80 the user aborted unzip prematurely with control-C (or
808 similar)
809
810 81 testing or extraction of one or more files failed due to
811 unsupported compression methods or unsupported decryp‐
812 tion.
813
814 82 no files were found due to bad decryption password(s).
815 (If even one file is successfully processed, however, the
816 exit status is 1.)
817
818 VMS interprets standard Unix (or PC) return values as other, scarier-
819 looking things, so unzip instead maps them into VMS-style status codes.
820 The current mapping is as follows: 1 (success) for normal exit,
821 0x7fff0001 for warning errors, and (0x7fff000? + 16*normal_un‐
822 zip_exit_status) for all other errors, where the `?' is 2 (error) for
823 unzip values 2, 9-11 and 80-82, and 4 (fatal error) for the remaining
824 ones (3-8, 50, 51). In addition, there is a compilation option to ex‐
825 pand upon this behavior: defining RETURN_CODES results in a human-
826 readable explanation of what the error status means.
827
829 Multi-part archives are not yet supported, except in conjunction with
830 zip. (All parts must be concatenated together in order, and then ``zip
831 -F'' (for zip 2.x) or ``zip -FF'' (for zip 3.x) must be performed on
832 the concatenated archive in order to ``fix'' it. Also, zip 3.0 and
833 later can combine multi-part (split) archives into a combined single-
834 file archive using ``zip -s- inarchive -O outarchive''. See the zip 3
835 manual page for more information.) This will definitely be corrected
836 in the next major release.
837
838 Archives read from standard input are not yet supported, except with
839 funzip (and then only the first member of the archive can be ex‐
840 tracted).
841
842 Archives encrypted with 8-bit passwords (e.g., passwords with accented
843 European characters) may not be portable across systems and/or other
844 archivers. See the discussion in DECRYPTION above.
845
846 unzip's -M (``more'') option tries to take into account automatic wrap‐
847 ping of long lines. However, the code may fail to detect the correct
848 wrapping locations. First, TAB characters (and similar control se‐
849 quences) are not taken into account, they are handled as ordinary
850 printable characters. Second, depending on the actual system / OS
851 port, unzip may not detect the true screen geometry but rather rely on
852 "commonly used" default dimensions. The correct handling of tabs would
853 require the implementation of a query for the actual tabulator setup on
854 the output console.
855
856 Dates, times and permissions of stored directories are not restored ex‐
857 cept under Unix. (On Windows NT and successors, timestamps are now re‐
858 stored.)
859
860 [MS-DOS] When extracting or testing files from an archive on a defec‐
861 tive floppy diskette, if the ``Fail'' option is chosen from DOS's
862 ``Abort, Retry, Fail?'' message, older versions of unzip may hang the
863 system, requiring a reboot. This problem appears to be fixed, but con‐
864 trol-C (or control-Break) can still be used to terminate unzip.
865
866 Under DEC Ultrix, unzip would sometimes fail on long zipfiles (bad CRC,
867 not always reproducible). This was apparently due either to a hardware
868 bug (cache memory) or an operating system bug (improper handling of
869 page faults?). Since Ultrix has been abandoned in favor of Digital
870 Unix (OSF/1), this may not be an issue anymore.
871
872 [Unix] Unix special files such as FIFO buffers (named pipes), block de‐
873 vices and character devices are not restored even if they are somehow
874 represented in the zipfile, nor are hard-linked files relinked. Basi‐
875 cally the only file types restored by unzip are regular files, directo‐
876 ries and symbolic (soft) links.
877
878 [OS/2] Extended attributes for existing directories are only updated if
879 the -o (``overwrite all'') option is given. This is a limitation of
880 the operating system; because directories only have a creation time as‐
881 sociated with them, unzip has no way to determine whether the stored
882 attributes are newer or older than those on disk. In practice this may
883 mean a two-pass approach is required: first unpack the archive nor‐
884 mally (with or without freshening/updating existing files), then over‐
885 write just the directory entries (e.g., ``unzip -o foo */'').
886
887 [VMS] When extracting to another directory, only the [.foo] syntax is
888 accepted for the -d option; the simple Unix foo syntax is silently ig‐
889 nored (as is the less common VMS foo.dir syntax).
890
891 [VMS] When the file being extracted already exists, unzip's query only
892 allows skipping, overwriting or renaming; there should additionally be
893 a choice for creating a new version of the file. In fact, the ``over‐
894 write'' choice does create a new version; the old version is not over‐
895 written or deleted.
896
898 funzip(1L), zip(1L), zipcloak(1L), zipgrep(1L), zipinfo(1L), zip‐
899 note(1L), zipsplit(1L)
900
902 The Info-ZIP home page is currently at
903 http://www.info-zip.org/pub/infozip/
904 or
905 ftp://ftp.info-zip.org/pub/infozip/ .
906
908 The primary Info-ZIP authors (current semi-active members of the Zip-
909 Bugs workgroup) are: Ed Gordon (Zip, general maintenance, shared code,
910 Zip64, Win32, Unix, Unicode); Christian Spieler (UnZip maintenance co‐
911 ordination, VMS, MS-DOS, Win32, shared code, general Zip and UnZip in‐
912 tegration and optimization); Onno van der Linden (Zip); Mike White
913 (Win32, Windows GUI, Windows DLLs); Kai Uwe Rommel (OS/2, Win32);
914 Steven M. Schweda (VMS, Unix, support of new features); Paul Kienitz
915 (Amiga, Win32, Unicode); Chris Herborth (BeOS, QNX, Atari); Jonathan
916 Hudson (SMS/QDOS); Sergio Monesi (Acorn RISC OS); Harald Denker (Atari,
917 MVS); John Bush (Solaris, Amiga); Hunter Goatley (VMS, Info-ZIP Site
918 maintenance); Steve Salisbury (Win32); Steve Miller (Windows CE GUI),
919 Johnny Lee (MS-DOS, Win32, Zip64); and Dave Smith (Tandem NSK).
920
921 The following people were former members of the Info-ZIP development
922 group and provided major contributions to key parts of the current
923 code: Greg ``Cave Newt'' Roelofs (UnZip, unshrink decompression); Jean-
924 loup Gailly (deflate compression); Mark Adler (inflate decompression,
925 fUnZip).
926
927 The author of the original unzip code upon which Info-ZIP's was based
928 is Samuel H. Smith; Carl Mascott did the first Unix port; and David P.
929 Kirschbaum organized and led Info-ZIP in its early days with Keith Pe‐
930 tersen hosting the original mailing list at WSMR-SimTel20. The full
931 list of contributors to UnZip has grown quite large; please refer to
932 the CONTRIBS file in the UnZip source distribution for a relatively
933 complete version.
934
936 v1.2 15 Mar 89 Samuel H. Smith
937 v2.0 9 Sep 89 Samuel H. Smith
938 v2.x fall 1989 many Usenet contributors
939 v3.0 1 May 90 Info-ZIP (DPK, consolidator)
940 v3.1 15 Aug 90 Info-ZIP (DPK, consolidator)
941 v4.0 1 Dec 90 Info-ZIP (GRR, maintainer)
942 v4.1 12 May 91 Info-ZIP
943 v4.2 20 Mar 92 Info-ZIP (Zip-Bugs subgroup, GRR)
944 v5.0 21 Aug 92 Info-ZIP (Zip-Bugs subgroup, GRR)
945 v5.01 15 Jan 93 Info-ZIP (Zip-Bugs subgroup, GRR)
946 v5.1 7 Feb 94 Info-ZIP (Zip-Bugs subgroup, GRR)
947 v5.11 2 Aug 94 Info-ZIP (Zip-Bugs subgroup, GRR)
948 v5.12 28 Aug 94 Info-ZIP (Zip-Bugs subgroup, GRR)
949 v5.2 30 Apr 96 Info-ZIP (Zip-Bugs subgroup, GRR)
950 v5.3 22 Apr 97 Info-ZIP (Zip-Bugs subgroup, GRR)
951 v5.31 31 May 97 Info-ZIP (Zip-Bugs subgroup, GRR)
952 v5.32 3 Nov 97 Info-ZIP (Zip-Bugs subgroup, GRR)
953 v5.4 28 Nov 98 Info-ZIP (Zip-Bugs subgroup, SPC)
954 v5.41 16 Apr 00 Info-ZIP (Zip-Bugs subgroup, SPC)
955 v5.42 14 Jan 01 Info-ZIP (Zip-Bugs subgroup, SPC)
956 v5.5 17 Feb 02 Info-ZIP (Zip-Bugs subgroup, SPC)
957 v5.51 22 May 04 Info-ZIP (Zip-Bugs subgroup, SPC)
958 v5.52 28 Feb 05 Info-ZIP (Zip-Bugs subgroup, SPC)
959 v6.0 20 Apr 09 Info-ZIP (Zip-Bugs subgroup, SPC)
960
961
962
963Info-ZIP 20 April 2009 (v6.0) UNZIP(1L)