关于linux:每天学一个-Linux-命令42unzip

6次阅读

共计 2543 个字符,预计需要花费 7 分钟才能阅读完成。

昨日举荐:每天学一个 Linux 命令(41):zip

命令简介

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

每天学一个 Linux 命令(38):vi/vim

每天学一个 Linux 命令(39):tar

每天学一个 Linux 命令(40):gzip

正文完
 0