Archive-Unzip-Burst
view release on metacpan or search on metacpan
unzip-6.0/zipinfo.txt view on Meta::CPAN
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 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. See the EXAMPLES section
below for a semi-intelligible translation of this nonsense.
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 com-
mand: OS/2 always reports the number of bytes required in 16-bit for-
mat, 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 environ-
ment 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 -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:
Unix Bourne shell:
ZIPINFO=-l; export ZIPINFO
Unix C shell:
setenv ZIPINFO -l
OS/2 or MS-DOS:
set ZIPINFO=-l
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: simply ignore the
first hyphen and go from there. It is also consistent with the behav-
ior of the Unix command nice(1).
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(1L), ZIPIN-
FOOPT is also accepted (don't ask). 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.
EXAMPLES
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 them-
selves or with each other, override any default listing of member
files; only the header and/or footer are printed. This behavior is
useful when zipinfo 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 for-
mat, 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 informa-
tion 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 ver-
sions 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.
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 exe-
cutable, 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.
BUGS
As with unzip, zipinfo's -M (``more'') option is overly simplistic in
its handling of screen output; as noted above, it fails to detect the
( run in 2.829 seconds using v1.01-cache-2.11-cpan-364913b4093 )