每天回顾linux命令(unzip)

unzip命令
unzip命令用于解压由zip命令压缩的“.zip”压缩包。

语法

unzip (选项) (参数)

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

root@35d388cf883b:/home/wzm/testgzip/zip# cat testzip
123
abc
root@35d388cf883b:/home/wzm/testgzip/zip# zip test.zip testzip
  adding: testzip (stored 0%)
root@35d388cf883b:/home/wzm/testgzip/zip# unzip -c test.zip
Archive:  test.zip
 extracting: testzip
123
abc

root@35d388cf883b:/home/wzm/testgzip/zip#

-f:更新现有的文件。
-l:显示压缩文件内所包含的文件。

root@35d388cf883b:/home/wzm/testgzip/ret# unzip -l test.zip
Archive:  test.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2017-11-21 03:19   zip/
    57764  2017-11-20 01:26   zip/redis.conf
        0  2017-11-21 02:25   zip/addfile.txt
        8  2017-11-21 02:11   zip/.testzip
---------                     -------
    57772                     4 files
root@35d388cf883b:/home/wzm/testgzip/ret#

-p:和-c参数类似,会将解压的结果显示到屏幕上,但不会执行任何的转换;
-t:检查压缩文件是否正确。

root@35d388cf883b:/home/wzm/testgzip/ret# unzip -t test.zip
Archive:  test.zip
    testing: zip/                     OK
    testing: zip/redis.conf           OK
    testing: zip/addfile.txt          OK
    testing: zip/.testzip             OK
No errors detected in compressed data of test.zip.
root@35d388cf883b:/home/wzm/testgzip/ret#

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

root@35d388cf883b:/home/wzm/testgzip/ret# unzip -u test.zip
Archive:  test.zip
   creating: zip/
  inflating: zip/redis.conf
 extracting: zip/addfile.txt
 extracting: zip/.testzip
root@35d388cf883b:/home/wzm/testgzip/ret# ls
test.zip  zip
root@35d388cf883b:/home/wzm/testgzip/ret#

-v:执行时显示详细的信息

root@35d388cf883b:/home/wzm/testgzip/ret# unzip -v test.zip
Archive:  test.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 2017-11-21 03:19 00000000  zip/
   57764  Defl:X    19974  65% 2017-11-20 01:26 6a80b091  zip/redis.conf
       0  Stored        0   0% 2017-11-21 02:25 00000000  zip/addfile.txt
       8  Stored        8   0% 2017-11-21 02:11 bd2b0b01  zip/.testzip
--------          -------  ---                            -------
   57772            19982  65%                            4 files
root@35d388cf883b:/home/wzm/testgzip/ret#

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

root@35d388cf883b:/home/wzm/testgzip/ret# unzip -z test.zip
Archive:  test.zip
root@35d388cf883b:/home/wzm/testgzip/ret#

-a:对文本进行必要的字符转换
-b:不要对文本进行必要的字符转换
-C:压缩文件的的文件名称区分大小写
-j:不处理压缩文件中原有的目录路径
-L:将压缩文件中的全部文件名改为小写
-n:解压缩时不覆盖原有的文件;
-o:不必先询问用户,覆盖原有文件

root@35d388cf883b:/home/wzm/testgzip/ret# unzip test.zip
Archive:  test.zip
replace zip/Testzip? [y]es, [n]o, [A]ll, [N]one, [r]ename:
root@35d388cf883b:/home/wzm/testgzip/ret# unzip -o test.zip                                                             Archive:  test.zip                                                                                                       extracting: zip/Testzip                                                                                                  inflating: zip/redis.conf                                                                                              extracting: zip/addfile.txt                                                                                            root@35d388cf883b:/home/wzm/testgzip/ret# 

-p密码:使用zip的密码选项
-q:执行时不显示任何信息

root@35d388cf883b:/home/wzm/testgzip/ret# rm zip -r
root@35d388cf883b:/home/wzm/testgzip/ret# unzip -q test.zip
root@35d388cf883b:/home/wzm/testgzip/ret# rm zip -r
root@35d388cf883b:/home/wzm/testgzip/ret# unzip test.zip
Archive:  test.zip
   creating: zip/
 extracting: zip/Testzip
  inflating: zip/redis.conf
 extracting: zip/addfile.txt
root@35d388cf883b:/home/wzm/testgzip/ret#

-s:将文件名中的空白字符转换为底线字符
-X:解压的同事回存文件原来的UID/GID
-d 目录:指定文件压缩后所要存储的目录
-x 文件:指定不要处理.zip压缩文件中的哪些文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值