SYNOPSIS
zipinfo
[
unzip
[
DESCRIPTION>
zipinfo lists technical information about files in a ZIP
archive.
Such information includes file access permissions, encryption
status, type of compression, version and operating system
or file system of compressing program, and the like. The
default behavior (with no options) is to list single-line
entries for each file in the archive, with header and
trailer lines providing summary information for the entire
archive. The format is a cross between ls
- Note:
-
The zipinfo utility uses the same executable as unzip. It is the equivalent to specifying unzip
-Z .
Arguments
- file[.zip]
-
Path of the ZIP archive(s). If the file specification contains a wildcard, each matching file is processed in an order determined by the operating system (or file system). Only the file name can be a wildcard; the path itself cannot. Wildcard expressions are similar to egrep (regular) expressions and may contain:
- Note:
-
Unless you specify the
-C option, zinpinfo matches file names in the ZIP archive on a case sensitive basis.
- *
-
matches a sequence of 0 or more characters.
- ?
-
matches exactly one character.
- [...]
-
matches any single character found inside the brackets; ranges are specified by a beginning character, a hyphen, and an ending character. If an exclamation point or a caret (! or ^) follows the left bracket, then the range of characters within the brackets is complemented (that is, anything except the characters inside the brackets is considered a match).
If no matches are found, the specification is assumed to be a literal file name; and if that also fails, the suffix .zip is appended. Note that self-extracting ZIP files are supported; just specify the .exe suffix (if any) explicitly.
- [file(s)]
-
An optional list of archive members to be processed. Regular expressions (wildcards) may be used to match multiple members; see above. Again, be sure to quote expressions that would otherwise be expanded or modified by the operating system.
- [
-x xfile(s)] -
An optional list of archive members to be excluded from processing.
-1 -
lists file names only, one per line. This option excludes all others; headers, trailers and zipfile comments are never printed. It is intended for use in Unix shell scripts.
-2 -
lists file names only, one per line, but allow headers (
-h ), trailers (-t ) and zipfile comments (-z ), as well. This option may be useful in cases where the stored file names are particularly long. -s -
lists zipfile info in short ls
-l format. This is the default behavior; see below. -m -
lists zipfile info in medium ls
-l format. This is identical to the-s output, except that the compression factor, expressed as a percentage, is also listed. -l -
lists zipfile info in long ls
-l format. This is identical to the-m , except that the compressed size (in bytes) is printed instead of the compression ratio. -v -
lists zipfile information in verbose, multi-page format.
-C -
matches file names in the ZIP archive on a case insensitive basis. For example, file1 would also match FILE1 and File1.
-h -
lists header line. The archive name, actual size (in bytes) and total number of files is printed.
-M -
pipes all output through an internal pager similar to the more command. At the end of a screenful of output, zipinfo pauses with a --More-- prompt; the next screenful may be viewed by pressing the Enter (Return) key or the space bar. zipinfo can be terminated by pressing the q key and, on some systems, the Enter/Return key. Unlike more, there is no forward-searching or editing capability. Also, zipinfo doesn't notice if long lines wrap at the edge of the screen, effectively resulting in the printing of two or more lines and the likelihood that some text will scroll off the top of the screen before being viewed. On some systems, the of available lines on the screen is not detected, in which case zipinfo assumes the height is 24 lines.
-t -
lists totals for files listed or for all files. The number of files listed, their uncompressed and compressed total sizes, and their overall compression factor are printed; or, if only the totals line is being printed, the values for the entire archive are given. Note that the total compressed (data) size will never match the actual zipfile size, since the latter includes all of the internal zipfile headers in addition to the compressed data.
-T -
prints the file dates and times in a sortable decimal format (yymmdd.hhmmss). The default date format is a more standard, human-readable version with abbreviated month names (see examples below).
-z -
includes the archive comment (if any) in the listing.
Detailed Description
The zipinfo utility has a number of modes, and its behavior can be rather difficult to fathom if one isn't familiar with ls ) (or even if one is). The default behavior is to list files in the following format:
-rw-rws--- 1.9 unx 2802 t- defX 11-Aug-91 13:48 perms.2660
The last three fields are the modification date and time of the file, and its name. The case of the file name is respected; thus files that come from MS-DOS PKZIP are always capitalized. If the file was zipped with a stored directory name, that is also displayed as part of the file name.
The second and third fields indicate that the file was zipped on a UNIX system with version 1.9 of zip. Since it comes from UNIX, the file permissions at the beginning of the line are printed in Unix format. The uncompressed filesize (2802 in this example) is the fourth field.
The fifth field consists of two characters, either of which may take on several values. The first character may be either t or b, indicating that zip believes the file to be text or binary, respectively; but if the file is encrypted, zipinfo notes this fact by capitalizing the character (T or B). The second character may also take on four values, depending on whether there is an extended local header and/or an extra field associated with the file (fully explained in PKWare's APPNOTE.TXT, but basically analogous to pragmas in ANSI C--that is, they provide a standard way to include non-standard information in the archive). If neither exists, the character will be a hyphen (-); if there is an extended local header but no extra field, l; if the reverse, x and if both exist, X. Thus the file in this example is (probably) a text file, is not encrypted, and has neither an extra field nor an extended local header associated with it. The example below, on the other hand, is an encrypted binary file with an extra field:
RWD,R,R 0.9 vms 168 Bx shrk 9-Aug-91 19:15 perms.0644
Extra fields are used for various purposes (see discussion
of the
-rw-a-- 1.0 hpf 5358 Tl i4:3 4-Dec-91 11:33 longfilename.hpfs -r--ahs 1.1 fat 4096 b- i4:2 14-Jul-91 12:58 EA DATA. SF --w------- 1.0 mac 17357 bx i8:2 4-May-92 04:02 unzip.macr
File attributes in the first two cases are indicated in a UNIX-like format, where the seven subfields indicate whether the file: (1) is a directory, (2) is readable (always true), (3) is writable, (4) is executable (guessed on the basis of the extension--.exe, .com, .bat, .cmd and .btm files are assumed to be so), (5) has its archive bit set, (6) is hidden, and (7) is a system file. Interpretation of Macintosh file attributes is unreliable because some Macintosh archivers don't store any attributes in the archive.
Finally, the sixth field indicates the compression method and possible sub-method used. There are six methods known at present: storing (no compression), reducing, shrinking, imploding, tokenizing (never publicly released), and deflating. In addition, there are four levels of reducing (1 through 4); four types of imploding (4K or 8K sliding dictionary, and 2 or 3 Shannon-Fano trees); and four levels of deflating (superfast, fast, normal, maximum compression). zipinfo represents these methods and their sub-methods as follows: stor; re:1, re:2, etc.; shrk; i4:2, i8:3, etc.; tokn; and defS, defF, defN, and defX.
The medium and long listings are almost identical to the short format except that they add information on the file's compression. The medium format lists the file's compression factor as a percentage indicating the amount of space that has been "removed":
-rw-rws--- 1.5 unx 2802 t- 81% defX 11-Aug-91 13:48 perms.2660
In this example, the file has been compressed by more than a factor of five; the compressed data are only 19% of the original size. The long format gives the compressed file's size in bytes, instead:
-rw-rws--- 1.5 unx 2802 t- 538 defX 11-Aug-91 13:48 perms.2660
Adding the
-rw-rws--- 1.5 unx 2802 t- 538 defX 910811.134804 perms.2660
Note that because of limitations in the MS-DOS format used to store file times, the seconds field is always rounded to the nearest even second.
In addition to individual file information, a default zipfile listing also includes header and trailer lines:
Archive: OS2.zip 5453 bytes 5 files ,,rw, 1.0 hpf 730 b- i4:3 26-Jun-92 23:40 Contents ,,rw, 1.0 hpf 3710 b- i4:3 26-Jun-92 23:33 makefile.os2 ,,rw, 1.0 hpf 8753 b- i8:3 26-Jun-92 15:29 os2unzip.c ,,rw, 1.0 hpf 98 b- stor 21-Aug-91 15:34 unzip.def ,,rw, 1.0 hpf 95 b- stor 21-Aug-91 17:51 zipinfo.def 5 files, 13386 bytes uncompressed, 4951 bytes compressed: 63.0%
The header line gives the name of the archive, its total
size, and the total number of files; the trailer gives the
number of files listed, their total uncompressed size, and
their total compressed size (not including any of zip's
internal overhead). If, however, one or more file(s) are
provided, the header and trailer lines are not listed.
This behavior is also similar to that of ls
The verbose listing is mostly self-explanatory. It also lists file comments and the zipfile comment, if any, and the type and number of bytes in any stored extra fields. Currently known types of extra fields include PKWARE's authentication (AV) info; OS/2 extended attributes; VMS file system info, both PKWARE and Info-ZIP versions; Macintosh resource forks; Acorn/Archimedes SparkFS info; and so on. (Note that in the case of OS/2 extended attributes--perhaps the most common use of zipfile extra fields--the size of the stored EAs as reported by zipinfo may not match the number given by OS/2's dir command: OS/2 always reports the number of bytes required in 16-bit format, whereas zipinfo always reports the 32-bit storage.)
Environment Options
Modifying zipinfo's default behavior via options placed in an environment variable can be a bit complicated to explain, due to zipinfo's attempts to handle various defaults in an intuitive, yet UNIX-like, manner. (Try not to laugh.) Nevertheless, there is some underlying logic. In brief, there are three "priority levels" of options: the default options; environment options, which can override or add to the defaults; and explicit options given by the user, which can override or add to either of the above.
The default listing format, as noted above, corresponds
roughly to the zipinfo
ZIPINFO=-l; export ZIPINFO MKS KornShell setenv ZIPINFO -l MKS C shell
If, in addition, the user dislikes the trailer line, zipinfo's concept of
"negative options" may be used to override the default inclusion of the line.
This is accomplished by preceding the undesired option with one or
more minuses: for example,
As suggested above, the default variable names are
ZIPINFO_OPTS for VMS (where the symbol used to install zipinfo
as a foreign command would otherwise be confused with the environment
variable), and ZIPINFO for all other operating systems.
For compatibility with zip, ZIPINFOOPT
is also accepted (don't ask). If both ZIPINFO and
ZIPINFOOPT are defined, however, ZIPINFO
takes precedence.
unzip's diagnostic option (
To get a basic, short-format listing of the complete contents of a ZIP archive storage.zip, with both header and totals lines, use only the archive name as an argument to zipinfo:
zipinfo storage
To produce a basic, long-format listing (not verbose),
including header and totals lines, use
zipinfo -l storage
To list the complete contents of the archive without
header and totals lines, either negate the
zipinfo --h-t storage zipinfo storage \*
(where the backslash is required only if the shell would otherwise expand the * wildcard, as in UNIX when globbing is turned on--double quotes around the asterisk would have worked as well). To turn off the totals line by default, use the environment variable (C shell is assumed here):
setenv ZIPINFO --t zipinfo storage
To get the full, short-format listing of the first example
again, given that the environment variable is set as in
the previous example, it is necessary to specify the
setenv ZIPINFO --t zipinfo -t storage [only totals line] zipinfo -st storage [full listing]
The
To list information on a single file within the archive, in medium format, specify the filename explicitly:
zipinfo -m storage unshrink.c
The specification of any member file, as in this example,
will override the default header and totals lines; only
the single line of information about the requested file
will be printed. This is intuitively what one would
expect when requesting information about a single file.
For multiple files, it is often useful to know the total
compressed and uncompressed size; in such cases
zipinfo -mt storage "*.[ch]" Mak\*
To get maximal information about the ZIP archive, use the verbose option. It is usually wise to pipe the output into a filter such as more:
zipinfo -v storage | more
Finally, to see the most recently modified files in the archive, use the -T option in conjunction with an external sorting utility such as sort (and tail as well, in this example):
zipinfo -T storage | sort -n +6 | tail -15
The
TIPS
The author finds it convenient to define an alias ii for zipinfo on systems that allow aliases (or, on other systems, copy/rename the executable, create a link or create a command file with the name ii). The ii usage parallels the common ll alias for long listings in UNIX, and the similarity between the outputs of the two commands was intentional.
PORTABILITY
All UNIX systems. Windows 2000. Windows XP. Windows Server 2003. Windows Vista. Windows 7. Windows Server 2008. Windows 8. Windows Server 2012.
zipinfo is also available other systems including MSDOS, OS/2, Minix, Atari, Macintosh, Amiga, and Acorn RISC OS.
AVAILABILITY
MKS Toolkit for Power Users
MKS Toolkit for System Administrators
MKS Toolkit for Developers
MKS Toolkit for Interoperability
MKS Toolkit for Professional Developers
MKS Toolkit for Enterprise Developers
MKS Toolkit for Enterprise Developers 64-Bit Edition
SEE ALSO
MKS Toolkit 9.5 Documentation Build 3.