zl程序教程

您现在的位置是:首页 >  其它

当前栏目

unzip

unzip
2023-09-27 14:26:42 时间
unzip
功能说明:unzip命令可以解压zip格式的文件。
 
参数选项:
-l   不解压显示压缩包的内容。
-a   指定解压目录
-o   解压时不提示是否覆盖文件。
-v   不会执行解压命令,只是显示详细信息。
 
 
查看压缩文件
[root@testdb ~]# touch a.log
[root@testdb ~]# ls -l a.log
-rw-r--r-- 1 root root 0 Dec 17 20:06 a.log
[root@testdb ~]# zip a.log.zip a.log
  adding: a.log (stored 0%)
[root@testdb ~]# ll a.log*
-rw-r--r-- 1 root root   0 Dec 17 20:06 a.log
-rw-r--r-- 1 root root 160 Dec 17 20:07 a.log.zip
[root@testdb ~]# unzip -l a.log
Archive:  a.log
  End-of-central-directory signature not found.  Either this file is not
  a zipfile, or it constitutes one disk of a multi-part archive.  In the
  latter case the central directory and zipfile comment will be found on
  the last disk(s) of this archive.
Archive:  a.log.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  12-17-2020 20:06   a.log
---------                     -------
        0                     1 file

 
常规解压的一些例子
说明:解压的文文件如果存在,会提示是否替换。-o参数解压时不提示是否覆盖。-v参数不会执行解压命令,只是查看。
[root@testdb ~]# ll a.log*
-rw-r--r-- 1 root root   0 Dec 17 20:06 a.log
-rw-r--r-- 1 root root 160 Dec 17 20:07 a.log.zip
[root@testdb ~]# unzip a.log.zip 
Archive:  a.log.zip
replace a.log? [y]es, [n]o, [A]ll, [N]one, [r]ename: y
 extracting: a.log                   
[root@testdb ~]# unzip -v a.log.zip
Archive:  a.log.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 12-17-2020 20:06 00000000  a.log
--------          -------  ---                            -------
       0                0   0%                            1 file
[root@testdb ~]# unzip -o a.log.zip
Archive:  a.log.zip
 extracting: a.log 
 
 
指定解压目录解压文件
[root@testdb ~]# ll a.log.zip 
-rw-r--r-- 1 root root 160 Dec 17 20:07 a.log.zip
[root@testdb ~]# ll a.log*
-rw-r--r-- 1 root root 160 Dec 17 20:07 a.log.zip
[root@testdb ~]# unzip -d /tmp/ a.log.zip
Archive:  a.log.zip
 extracting: /tmp/a.log              
[root@testdb ~]# ll /tmp/a.log*
-rw-r--r-- 1 root root 0 Dec 17 20:06 /tmp/a.log