117

How do I list the contents of a zip along w/ file sizes and compression ratio (or packed size) on osx w/ command line tools?

2 Answers 2

172

You have this tagged with both zip and gzip, but here's both. These are both pretty standard Unix tools, whic Mac OS X supports (as far as I know, anyway):

zip file: unzip -vl file.zip

Example:

[23:02:22] ~/Download $ unzip -vl lightbox2.04.zip 
Archive:  lightbox2.04.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 03-10-2008 00:57 00000000  css/
    1648  Defl:N      647  61% 03-10-2008 00:57 c3b9f4d9  css/lightbox.css
       0  Stored        0   0% 03-10-2008 00:57 00000000  images/
      49  Defl:N       44  10% 04-07-2007 20:58 64aff4e0  images/bullet.gif
     222  Defl:N      213   4% 04-07-2007 20:58 10131ca6  images/close.gif
     979  Defl:N      916   6% 04-07-2007 20:58 0415e19c  images/closelabel.gif
     723  Defl:N      728  -1% 04-07-2007 20:58 f3abf2ca  images/donate-button.gif
...
--------          -------  ---                            -------
  244588            94624  61%                            20 files
[23:02:36] ~/Download $ 

gzip file: gunzip -lv file.gz

Example:

[23:03:55] ~/Download $ gunzip -lv mudlet.tar.gz 
method  crc     date  time           compressed        uncompressed  ratio uncompressed_name
defla 768774be Feb 14 22:44             2895270             6533120  55.7% mudlet.tar
[23:04:02] ~/Download $ 
2
  • Just for completeness, there's also "bunzip2 -tv file.bz2" for those using bzip2.
    – TextGeek
    May 9, 2018 at 18:11
  • 1
    -l is for the listing, -v is for the compression stuff.
    – CodeFinity
    Dec 16, 2021 at 14:43
31

On Max OS X and Linux, you can use zipinfo:

zipinfo -m my_file.zip > list_my_file.txt

Output (more list_my_file.txt):

Archive:  my_file.zip
Zip file size: 3220317423 bytes, number of entries: 1998436
drwxrwxr-x  3.0 unx        0 bx  0% stor 15-Nov-26 07:14 p/
-rw-rw-r--  3.0 unx     4666 tx 77% defN 15-Nov-23 23:31 p/r2082514.json
-rw-rw-r--  3.0 unx     4278 tx 78% defN 15-Nov-21 16:39 p/r1190647.json
-rw-rw-r--  3.0 unx     4147 tx 77% defN 15-Nov-23 03:29 p/r1867235.json
-rw-rw-r--  3.0 unx     6866 tx 74% defN 15-Nov-23 01:25 p/r1814510.json
-rw-rw-r--  3.0 unx     6979 tx 78% defN 15-Nov-22 19:40 p/r1675696.json
-rw-rw-r--  3.0 unx     5460 tx 78% defN 15-Nov-22 23:11 p/r1761107.json
-rw-rw-r--  3.0 unx     4960 tx 74% defN 15-Nov-23 00:58 p/r1801562.json
-rw-rw-r--  3.0 unx     6459 tx 75% defN 15-Nov-21 19:00 p/r1261556.json

The flag -m displays the compression ratio:

-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.
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .