linux zip/unzip命令详解

2019-10-13 15:26:36王旭

-z   替 压缩文件加上注释。

-$   保 存第一个被压缩文件所在磁盘的卷册名称。

-<压缩效率>   压 缩效率是一个介于1-9的 数值。

例子

例1. 压缩test.MYI 

[root@mysql test]# zip test1.zip test.MYI

adding: test.MYI (deflated 42%)

[root@mysql test]#ll

-rw-r--r-- 1 root  root  1033755 09-24 10:03 test1.zip

压缩率为8的

[root@mysql test]# zip test2.zip -8 test.MYI

adding: test.MYI (deflated 42%)

[root@mysql test]#ll

-rw-r--r-- 1 root  root  1033451 09-24 10:03 test2.zip

例2.   将当前目录下的所有文件和文件夹全部压缩成test.zip文件,-r表示递归压缩子目录下所有文件

[root@mysql test]# zip -r test.zip ./*

打包目录

[root@mysql test]# zip test2.zip test2/*

例3.   删除压缩文件test1.zip中test.MYI文件

[root@mysql test]# zip -d test1.zip test.MYI

删除打包文件目录下的文件

 [root@mysql test]# zip -d test2.zip test2/ln.log

deleting: tests/ln.log

例4.   向压缩文件中test1.zip中添加test. MYI文件

[root@mysql test]# zip -m test1.zip test. MYI

例5.   压缩文件时排除某个文件

[root@mysql test]# zip test3.zip tests/* -x tests/ln.log

命令名: unzip

功 能说明:解压缩zip文 件

语  法:unzip [-cflptuvz][-agCjLMnoqsVX][-P <密 码>][.zip文 件][文件][-d <目录>][-x <文件>] 或 unzip [-Z]

补充说明:unzip为.zip压缩文件的解压缩程序。

参  数:

-c   将 解压缩的结果显示到屏幕上,并对字符做适当的转换。

-f   更 新现有的文件。

-l   显 示压缩文件内所包含的文件。

-p   与-c参数类似,会将解压缩的结果显示到屏幕上,但不会执行任 何的转换。

-t   检 查压缩文件是否正确。,但不解压。

-u   与-f参数类似,但是除了更新现有的文件外,也会将压缩文件中 的其他文件解压缩到目录中。

-v   执 行是时显示详细的信息。或查看压缩文件目录,但不解压。

-z   仅 显示压缩文件的备注文字。

-a   对 文本文件进行必要的字符转换。

-b   不 要对文本文件进行字符转换。

-C   压 缩文件中的文件名称区分大小写。

-j   不 处理压缩文件中原有的目录路径。

-L   将 压缩文件中的全部文件名改为小写。

-M   将 输出结果送到more程 序处理。

-n   解 压缩时不要覆盖原有的文件。