Linux zipinfo command

Updated: 05/04/2019 by Computer Hope
zipinfo command

On Unix-like operating systems, the zipinfo command lists technical information about a ZIP archive.

This document covers the Linux version of zipinfo.


zipinfo lists technical information about files in a zip archive, most commonly found on MS-DOS systems. Such information includes file access permissions, encryption status, type of compression, version and operating system or file system of compressing program. 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 Unix "ls -l" and "unzip -v" output. Note that zipinfo is the same program as unzip (under Unix, a link to it); on some systems, however, zipinfo support may have been omitted when unzip was compiled.


zipinfo [-12smlvhMtTz] file[.zip] [file(s) ...] [-x xfile(s) ...]


The zipinfo command takes the following arguments:

file[.zip] Path of the zip archive(s). If the file specification is 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 Unix egrep regular expressions, and may contain:

* matches a sequence of 0 or more characters.
? matches exactly 1 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). To specify a verbatim left bracket, the three-character sequence "[[]" has to be used.
(Be sure to quote any character that might otherwise be interpreted or modified by the operating system, particularly under Unix and VMS.) 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, as with any other zip archive; just specify the .exe suffix (if any) explicitly.
file ... An optional list of archive members to be processed, separated by spaces. Regular expressions or 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 ... An optional list of archive members to be excluded from processing.


-1 List 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 List 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 List zipfile info in short Unix "ls -l" format. This is the default behavior.
-m List zipfile info in medium Unix "ls -l" format. Identical to the -s output, except that the compression factor, expressed as a percentage, is also listed.
-l List zipfile info in long Unix "ls -l" format. As with -m except that the compressed size (in bytes) is printed instead of the compression ratio.
-v List zipfile information in verbose, multi-page format.
-h List header line. The archive name, actual size (in bytes) and total number of files is printed.
-M Pipe 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 spacebar. 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 number of available lines on the screen is not detected, in which case zipinfo assumes the height is 24 lines.
-t List totals for files listed or for all files. The number of files listed, their uncompressed and compressed total sizes, and their overall compression factor is printed; or, if only the totals line is being printed, the values for the entire archive are given. The compressed total size does not include the 12 additional header bytes of each encrypted entry. 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 Print 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.
-U Modify or disable UTF-8 handling. When UNICODE_SUPPORT is available, the option -U forces unzip to escape all non-ASCII characters from UTF-8 coded file names as "#Uxxxx". This option is mainly provided for debugging purpose when the fairly new UTF-8 support is suspected to mangle up extracted file names.

The option -UU allows to entirely disable the recognition of UTF-8 encoded file names. The handling of file name codings within unzip falls back to the behaviour of previous versions.
-z Include the archive comment (if any) in the listing.

Technical Details

zipinfo has a number of modes, and its behavior can be rather difficult to fathom if one isn't familiar with Unix ls. 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 under Unix 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 file-size (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. 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 or an "extra field" associated with the file (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 -v option below) including the storage of VMS file attributes, which is presumably the case here. These file attributes are listed in VMS format. Some other possibilities for the host operating system (which is actually a misnomer--host file system is more correct) include OS/2 or NT with High Performance File System (HPFS), MS-DOS, OS/2 or NT with File Allocation Table (FAT) file system, and Macintosh. These are denoted as follows:

-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:

  • is a directory,
  • is readable (always true),
  • is writable,
  • is executable (guessed on the basis of the extension; .exe, .com, .bat, .cmd and .btm files are assumed to be so),
  • has its archive bit set,
  • is hidden, and
  • 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. Also, 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 (super fast, 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

In contrast to the unzip listings, the compressed size figures in this listing format denote the complete size of compressed data, including the 12 extra header bytes in case of encrypted entries.

Adding the -T option changes the file date and time to decimal format:

-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. For Unix files this is expected to change in the next major releases of zip and unzip.

In addition to individual file information, a default zipfile listing also includes header and trailer lines:

Archive:   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 Unix's "ls -l"; it may be overridden by specifying the -h and -t options explicitly. In such a case the listing format must also be specified explicitly, since -h or -t (or both) in the absence of other options implies that ONLY the header or trailer line (or both) is listed.

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 filesystem 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.)

Again, the compressed size figures of the individual entries include the 12 extra header bytes for encrypted entries. In contrast, the archive total compressed size and the average compression ratio shown in the summary bottom line are calculated without the extra 12 header bytes of encrypted entries.

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. 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 -hst" command (except when individual zipfile members are specified). A user who prefers the long-listing format (-l) can make use of the zipinfo's environment variable to change this default using the following methods:

in Unix Bourne shell:


in Unix C shell:

setenv ZIPINFO -l

in OS/2 or MS-DOS:

set ZIPINFO=-l

in VMS (quotes for lowercase):

define ZIPINFO_OPTS "-l"

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: e.g., "-l-t" or "--tl", in this example. The first hyphen is the regular switch character, but the one before the "t" is a minus sign. The dual use of hyphens may seem a little awkward, but it's reasonably intuitive nonetheless: ignore the first hyphen and go from there. It is also consistent with the behavior of the Unix command nice.

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. If both ZIPINFO and ZIPINFOOPT are defined, however, ZIPINFO takes precedence. unzip's diagnostic option (-v with no zipfile name) can be used to check the values of all four possible unzip and zipinfo environment variables.


zipinfo hope

Display information about the archive Output will resemble the following:

Archive: 9628445 bytes 25 files
-rw-r--r-- 2.3 unx    282667  tx  defN  18-Jul-11 14:17 badips.txt
-rw-r--r-- 2.3 unx  46177980  tx  defN  18-Jul-11 04:45 hijacklogs.txt
-rw-r--r-- 2.3 unx    231984  tx  defN  18-Jul-11 13:01 isitup.txt
25 files, 60757943 bytes uncompressed, 9625041 bytes compressed: 84.2%

unzip — List, test and extract compressed files in a zip archive.
zip — A compression and archiving utility.