linux用unzip命令解压zip命令压缩的压缩包
admin
2023-07-30 20:07:55
0

命令简介

unzip 命令用于解压由zip命令压缩的压缩包文件。

#Debian/Ubuntu安装
apt-get install unzip

#CentOS安装
[root@centos7 ~]# unzip 
-bash: unzip: command not found
[root@centos7 ~]# yum install unzip -y

语法格式

unzip [ OPTIONS ] file[.zip] [file(s) ...]

选项说明

-c  #将解压缩的结果输出,并对字符做适当的转换
-f  #更新现有的文件
-l  #列出压缩文件内所包含的文件
-p  #将解压缩的结果显示到屏幕上,但不执行任何的转换
-t  #检查压缩文件是否正确;
-u  #除了更新现有的文件外,也会将压缩文件中的其他文件解压缩到目录中
-v  #显示详细的信息
-z  #仅显示压缩文件的备注信息
-a  #对文本文件进行必要的字符转换
-b  #不对文本文件进行字符转换
-C  #压缩文件名称区分大小写
-j  #不处理压缩文件中原有的目录路径
-L  #将压缩文件中的全部文件名改为小写
-M  #将输出结果再交给more程序处理
-n  #解压缩时不覆盖原有的文件
-o  #unzip执行后覆盖原有的文件,不提示
-P<密码>  #使用zip的密码选项
-q  #不显示任何命令执行过程信息
-s  #将文件名中的空白字符转换为底线字符
-d<目录>  #将解压缩后存至指定的目录下
-x<文件>  #指定不要处理.zip压缩文件中的哪些文件
-Z  #unzip-Z相当于执行zipinfo命令

应用举例

解压一个文件

[root@centos7 testdir]# unzip mingongge.zip

查看一个压缩文件但不解压

[root@centos7 testdir]# unzip -v mingongge.zip 
Archive:  mingongge.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
      59  Stored       59   0% 01-16-2021 12:15 b32621da  cest.txt.gz
      57  Stored       57   0% 01-16-2021 12:12 cbda1ce8  cuttest.txt.gz
       0  Stored        0   0% 01-16-2021 16:18 00000000  dir/
       0  Stored        0   0% 01-16-2021 16:18 00000000  file
      81  Stored       81   0% 01-16-2021 09:55 da9f2476  mingongge1.txt.gz
      51  Stored       51   0% 01-16-2021 03:36 8fdf382e  mingongge2.txt.gz
      87  Stored       87   0% 01-16-2021 09:59 982ab7bb  mingongge.txt.md5.gz
      65  Stored       65   0% 01-16-2021 10:19 17350869  sort.cut.txt.gz
--------          -------  ---                            -------
     400              400   0%                            8 files

指定解压后的文件存放目录

[root@centos7 testdir]# unzip -n mingongge.zip -d /tmp/
Archive:  mingongge.zip
 extracting: /tmp/cest.txt.gz        
 extracting: /tmp/cuttest.txt.gz     
   creating: /tmp/dir/
 extracting: /tmp/file               
 extracting: /tmp/mingongge1.txt.gz  
 extracting: /tmp/mingongge2.txt.gz  
 extracting: /tmp/mingongge.txt.md5.gz  
 extracting: /tmp/sort.cut.txt.gz    
[root@centos7 testdir]# ll /tmp/
total 24
-rw-r--r-- 1 root root 59 Jan 16 12:15 cest.txt.gz
-rw-r--r-- 1 root root 57 Jan 16 12:12 cuttest.txt.gz
drwxr-xr-x 2 root root  6 Jan 16 16:18 dir
-rw-r--r-- 1 root root  0 Jan 16 16:18 file
-rw-r--r-- 1 root root 81 Jan 16 09:55 mingongge1.txt.gz
-rw-r--r-- 1 root root 51 Jan 16 03:36 mingongge2.txt.gz
-rw-r--r-- 1 root root 87 Jan 16 09:59 mingongge.txt.md5.gz
-rw-r--r-- 1 root root 65 Jan 16 10:19 sort.cut.txt.gz

相关内容

热门资讯

Mobi、epub格式电子书如... 在wps里全局设置里有一个文件关联,打开,勾选电子书文件选项就可以了。
定时清理删除C:\Progra... C:\Program Files (x86)下面很多scoped_dir开头的文件夹 写个批处理 定...
scoped_dir32_70... 一台虚拟机C盘总是莫名奇妙的空间用完,导致很多软件没法再运行。经过仔细检查发现是C:\Program...
小程序支付时提示:appid和... [Q]小程序支付时提示:appid和mch_id不匹配 [A]小程序和微信支付没有进行关联,访问“小...
500 行 Python 代码... 语法分析器描述了一个句子的语法结构,用来帮助其他的应用进行推理。自然语言引入了很多意外的歧义,以我们...
pycparser 是一个用... `pycparser` 是一个用 Python 编写的 C 语言解析器。它可以用来解析 C 代码并构...
微信小程序使用slider实现... 众所周知哈,微信小程序里面的音频播放是没有进度条的,但最近有个项目呢,客户要求音频要有进度条控制,所...
65536是2的几次方 计算2... 65536是2的16次方:65536=2⁶ 65536是256的2次方:65536=256 6553...
Apache Doris 2.... 亲爱的社区小伙伴们,我们很高兴地向大家宣布,Apache Doris 2.0.0 版本已于...
项目管理和工程管理的区别 项目管理 项目管理,顾名思义就是专注于开发和完成项目的管理,以实现目标并满足成功标准和项目要求。 工...