如何使用命令行工具在 osx 上列出 zip 的内容以及文件大小和压缩率(或打包大小)?
答案1
您已将其标记为 zip 和 gzip,但这里同时标记了这两个。 这两个都是非常标准的 Unix 工具,Mac OS X 也支持它们(至少据我所知):
压缩文件:unzip -vl file.zip
例子:
[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 文件:gunzip -lv file.gz
例子:
[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
在 Max OS X 和 Linux 上,您可以使用邮编信息:
zipinfo -m my_file.zip > list_my_file.txt
输出 (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
该标志-m
显示压缩率:
-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.