曲径通幽论坛

 找回密码
 立即注册
搜索
查看: 4180|回复: 0
打印 上一主题 下一主题

zip/unzip -- zip 格式压缩/解压缩工具

[复制链接]

4918

主题

5880

帖子

3万

积分

GROAD

曲径通幽,安觅芳踪。

Rank: 6Rank: 6

积分
34387
跳转到指定楼层
楼主
发表于 2012-4-11 23:27:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
zip 压缩非常流行,不像 gzip 和 bzip2 那样通常用在 Linux 上,它在多种平台上都有使用。一般使用格式是:
# zip nohup.out.zip nohup.out
  adding: nohup.out (deflated 94%)
# ls -l nohup.out*
-rw------- 1 root root 195515 2011-05-28 nohup.out
-rw-r--r-- 1 root root  12681 04-11 10:55 nohup.out.zip

使用 -r 选项递归压缩目录
# zip -r command.zip command/ delay.sh
  adding: command/ (stored 0%)
  adding: command/ver.patch (deflated 33%)
  adding: command/hello.c (deflated 24%)
... ...
  adding: command/ver1.txt (deflated 23%)
  adding: command/cut/ (stored 0%)
  adding: command/cut/temp.txt (deflated 70%)
  adding: delay.sh (deflated 25%)

解压缩 zip 包使用 unzip 命令,如:
unzip command.zip
不像 gunzip 和 unlzma 那样,在解压缩后会删除掉压缩包,unzip 解压缩后仍然保留压缩包。

可以用 unzip 的 -l 选项查看压缩包中的文件:
# unzip -l command.zip
Archive:  command.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2012-04-05 12:12   command/
      178  2012-04-03 12:15   command/ver.patch
      122  2012-04-03 21:19   command/hello.c
        0  2012-04-05 22:25   command/paste/
       10  2012-04-05 12:13   command/paste/3.txt
      113  2012-04-05 22:11   command/paste/iterline.sh
       82  2012-04-05 22:25   command/paste/tmp2.sh
       97  2012-04-05 22:15   command/paste/tmp.sh
       42  2012-04-05 12:22   command/paste/mulword.txt
       10  2012-04-05 12:13   command/paste/1.txt
       10  2012-04-05 12:13   command/paste/2.txt
       35  2012-04-03 10:08   command/ver2.txt
       35  2012-04-03 12:15   command/ver1.txt
        0  2012-04-04 09:48   command/cut/
      108  2012-04-04 09:48   command/cut/temp.txt
      170  2012-03-21 13:57   delay.sh
---------                     -------
     1012                     16 files

如果要从 zip 包中删除一个文件,那么可以用 -d 选项,如:
# zip -d command.zip delay.sh
deleting: delay.sh

如果要更新压缩包中的文件,那么可用 -u 选项:
$ zip file.zip -u newfile
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )

GMT+8, 2024-6-2 20:59 , Processed in 0.065225 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表