
6.3 zip软件包管理
Zip是计算机文件的压缩的算法,原名deflate(真空),发明者为菲利普•卡兹(Phil Katz),他于1989年1月公布了该格式的资料。zip软件包命名后缀通常使用zip。
主流的压缩格式包括tar、rar、zip、war、gzip、bz2、iso等。性能上tar、war、rar格式比zip格式压缩率较高,但压缩时间远远高于zip。zip工具可以实现对zip包进行管理,也可以将文件和文件夹打包成zip包。zip工具打包常见参数详解如下:
□-f:只更改文件。
□-u:只更改或更新文件。
□-d:从压缩文件删除文件。
□-m:将条目移动到zipfile(删除OS文件)。
□-r:递归到目录。
□-j:junk(不记录)目录名。
□-l:将LF转换为CR LF(-11 CR LF~LF)。
□-1:压缩更快,1~9压缩更好。
□-q:安静操作,不输出执行的过程。
□-v:verbose操作/打印版本信息。
□-c:添加一行注释。
□-z:添加zipfile注释。
□-o:读取名称使zip文件与最新条目一样旧。
□-x:不包括以下名称。
□-F:修复zipfile(-FF尝试更难)。
□-D:不要添加目录条目。
□-T:测试zip文件完整性。
□-X:eXclude、eX tra文件属性。
□-e:加密“-”,不要压缩这些后缀。
□-h2:显示更多的帮助。
Zip企业案例演示:
(1)通过zip工具打包jingfeng文件夹中所有内容,如图6-4所示。

图6-4 zip工具对jingfeng目录打包备份

(2)通过zip工具打包jingfeng文件夹中所有内容并排除部分文件,如图6-5所示。

图6-5 zip对jingfeng目录打包备份,排除部分文件

(3)通过zip工具删除jingfeng.zip中jf3.txt文件,如图6-6所示。

图6-6 unzip对jingfeng目录解压

(4)通过unzip工具解压jingfeng.zip文件,如图6-6所示。

注意:可以用-d指定解压后的目录。