unzip命令用于解压缩zip格式文件,虽然Linux系统中更多地使用tar命令进行对压缩包的管理操作,但有时也会收到Windows系统常用的.zip和.rar格式的压缩包文件,unzip命令便派上了用场。直接使用unzip命令解压缩文件后,压缩包内原有的文件会被提取并输出保存到当前工作目录下。

语法格式:unzip [参数] 压缩包名

常用参数:

-a 对文本进行必要的字符转换
-b 不要对文本进行任何字符转换
-c 适当转换字符后输出解压缩结果
-C 严格区分大小写
-d 解压缩文件到指定目录中
-f 强制覆盖已有文件
-j 不处理压缩文件中原有的目录路径
-l 显示压缩包内文件列表
-L 将压缩包内文件名改为小写
-n 解压缩时不覆盖已有文件
-p 使用密码加密
-q 静默执行模式
-t 检查压缩包完整性
-v 显示执行过程详细信息
-x 跳过压缩包内的指定文件
-z 显示压缩包内的备注文字

参考示例

将压缩包文件解压到当前工作目录中:

[root@linuxcool ~]# unzip File.zip
Archive:  File.zip
creating: wordpress/
inflating: wordpress/xmlrpc.php
inflating: wordpress/wp-blog-header.php
inflating: wordpress/readme.html
inflating: wordpress/wp-signup.php
inflating: wordpress/index.php
………………省略部分输出信息………………

将压缩包文件解压到指定目录中:

[root@linuxcool ~]# unzip File.zip -d /home
Archive:  File.zip
creating: /home/wordpress/
inflating: /home/wordpress/xmlrpc.php
inflating: /home/wordpress/wp-blog-header.php
inflating: /home/wordpress/readme.html
inflating: /home/wordpress/wp-signup.php
inflating: /home/wordpress/index.php
………………省略部分输出信息………………

测试压缩包文件是否完整,文件有无损坏:

[root@linuxcool ~]# unzip -t File.zip
Archive:  File.zip
testing: wordpress/                     OK
testing: wordpress/xmlrpc.php           OK
testing: wordpress/wp-blog-header.php   OK
testing: wordpress/readme.html          OK
testing: wordpress/wp-signup.php        OK
testing: wordpress/index.php            OK
………………省略部分输出信息………………
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。