Linux之unzip命令

  • 命令概述

unzip - 列出、测试和提取 ZIP 存档中的压缩文件;

  • 命令语法
unzip [-Z] [-cflptTuvz[abjnoqsCDKLMUVWX$/:^]] file[.zip] [file(s) ...] [-x xfile(s) ...] [-d exdir]

  • 命令参数

-f

更新压缩包的文件;

-l

显示压缩文件内的文件;

-v

执行时显示详细的信息;

-o

不询问用户,覆盖原有文件;

-q

不显示执行过程;

-d

指定文件解压缩后所要存储的目录;

  • 命令示例

1、unzip test5.zip 解压压缩文件test5.zip到当前目录;

[root@localhost test]# unzip test5.zip
Archive:  test5.zip
  inflating: test5.txt               
[root@localhost test]# ll
-rw-r--r-- 1 root root   50 Jul 16 14:50 test5.txt
-rw-r--r-- 1 root root  216 Jul 17 14:28 test5.zip

2、unzip -l test5.zip -l 表示在不解压的情况下查看压缩文件内的文件;

[root@localhost test]# unzip -l  test5.zip
Archive:  test5.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       50  07-16-2022 14:50   test5.txt
---------                     -------
       50                     1 file

3、unzip -v test5.zip -v 表示在不解压的情况下查看压缩文件内的文件,且显示更多信息(压缩比率等);

[root@localhost test]# unzip -v test5.zip
Archive:  test5.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
      50  Defl:N       48   4% 07-16-2022 14:50 7fa7173c  test5.txt
--------          -------  ---                            -------
      50               48   4%                            1 file

4、unzip -q test.zip -q 表示不显示执行过程;

[root@localhost data]# unzip -q test.zip

5、unzip -o test.zip -o 表示不询问用户,覆盖原有文件;

[root@localhost data]# unzip test.zip
Archive:  test.zip
replace data/test/test1.txt? [y]es, [n]o, [A]ll, [N]one, [r]ename: ^Z
[1]+  Stopped                 unzip test.zip
[root@localhost data]# unzip -o test.zip
Archive:  test.zip
 extracting: data/test/test2.zip

 6、unzip -q -d /data/test/test5 test.zip(unzip -q test.zip -d /data/test/test5) -d 表示指定文件解压缩后所要存储的目录(-d 后面必须接路径,不然会报错,且当路径不存在时会自动创建);

[root@localhost data]# unzip  -d -q /data/test/test5  test.zip
error:  must specify directory to which to extract with -d option
[root@localhost data]# unzip -q -d /data/test/test5  test.zip
[root@localhost data]# ll
-rw-r--r-- 1 root  root     0 Jul 16 12:37 test.txt
  • 5
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值