in reply to Re: Reading the Zipped Files.
in thread Reading the Zipped Files.

This won't work as the *.out will be expanded by the shell and attempt to match out files within the current directory in the zip file. This is the way by which I would do this ...

unzip -l archive.zip | grep \.out$ | awk '{ print $4 }' | xargs unzip +archive.zip

Note however, I would not call this portable because it is dependent upon the output of the unzip binary to place the file name of archive members as the fourth element on the line (which is at least what unzip on our Solaris development box does). A more portable overall method would be to use Archive::Zip such as suggested by the ever venerable Anonymous Monk here rather than depending upon the output of external binaries.

 

perl -le 'print+unpack"N",pack"B32","00000000000000000000001001100101"'

Replies are listed 'Best First'.
Re^3: Reading the Zipped Files.
by Aristotle (Chancellor) on Jun 04, 2003 at 00:05 UTC
    Useless use of grep (besides the fact it's not even necessary as you can quote the glob and pass it to unzip):
    awk '/\.out$/ { print $4 }'

    Makeshifts last the longest.

Re: Re: Re: Reading the Zipped Files.
by Anonymous Monk on Jun 03, 2003 at 22:58 UTC

    The shell will expand the star only if there are *.out files in the current directory. However, quoting the pattern, the snippet works as advertized.

    unzip -l archive.zip "*.out" | perl -ne 'if (/(\S+\.out)$/){ print $1, +" ", `unzip -p archive.zip $1`, $/}'

    The purpose of this snippet was to emphasize that artist is doing something unnecessarily complicated. Since his method is not portable, at least he should try not to waste resources. ;)