zipinfo command examples

zipinfo command examples

zipinfo – list detailed information about a ZIP archive

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

zipinfo -l storage

To list the complete contents of the archive without header and totals lines, either negate the -h and -t options or else specify the contents explicitly:

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 -s option explicitly, since the -t option by itself implies that ONLY the footer line is to be printed:

setenv ZIPINFO --t
zipinfo -t storage [only totals line]
zipinfo -st storage [full listing]

The -s option, like -m and -l, includes headers and footers by default, unless otherwise specified. Since the environment variable specified no footers and that has a higher precedence than the default behavior of -s, an explicit -t option was necessary to produce the full listing. Nothing was indicated about the header, however, so the -s option was sufficient. Note that both the -h and -t options, when used by themselves or with each other, override any default listing of member files; only the header and/or footer are printed. This behavior is useful when zip‐info is used with a wildcard zipfile specification; the contents of all zipfiles are then summarized with a single command.

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 -t may be specified explicitly:

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 Unix more(1) if the operating system allows it:

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 Unix sort(1) (and sed(1) as well, in this example):

zipinfo -T storage | sort -nr -k 7 | sed 15q

The -nr option to sort(1) tells it to sort numerically in reverse order rather than in textual order, and the -k 7 option tells it to sort on the seventh field. This assumes the default short-listing format; if -m or -l is used, the proper sort(1) option would be -k 8. Older versions of sort(1) do not support the -k option, but you can use the traditional + option instead, e.g., +6 instead of -k 7. The sed(1) command filters out all but the first 15 lines of the listing. Future releases of zipinfo may incorporate date/time and filename sorting as built-in options.

Leave a Reply

Your email address will not be published. Required fields are marked *