【Linux】一步一步学Linux——unzip命令(68)
发布日期:2021-06-29 21:00:00 浏览次数:2 分类:技术文章

本文共 2696 字,大约阅读时间需要 8 分钟。

00. 目录

文章目录

01. 命令概述

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

默认行为(就是没有选项)是从指定的ZIP存档中提取所有的文件到当前目录(及其下面的子目录)。一个配套程序zip(1L)创建ZIP存档;这两个程序都与PKWARE的PKZIP和PKUNZIP为MS-DOS创建的存档文件兼容,但许多情况下,程序选项或默认行为是不同的。

02. 命令格式

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

03. 常用选项

-c:将解压缩的结果显示到屏幕上,并对字符做适当的转换;-f:更新现有的文件;-l:显示压缩文件内所包含的文件;-p:与-c参数类似,会将解压缩的结果显示到屏幕上,但不会执行任何的转换;-t:检查压缩文件是否正确;-u:与-f参数类似,但是除了更新现有的文件外,也会将压缩文件中的其他文件解压缩到目录中;-v:执行时显示详细的信息;-z:仅显示压缩文件的备注文字;-a:对文本文件进行必要的字符转换;-b:不要对文本文件进行字符转换;-C:压缩文件中的文件名称区分大小写;-j:不处理压缩文件中原有的目录路径;-L:将压缩文件中的全部文件名改为小写;-M:将输出结果送到more程序处理;-n:解压缩时不要覆盖原有的文件;-o:不必先询问用户,unzip执行后覆盖原有的文件;-P
<密码>
:使用zip的密码选项;-q:执行时不显示任何信息;-s:将文件名中的空白字符转换为底线字符;-V:保留VMS的文件版本信息;-X:解压缩时同时回存文件原来的UID/GID;-d
<目录>
:指定文件解压缩后所要存储的目录;-x
<文件>
:指定不要处理.zip压缩文件中的哪些文件;-Z:unzip-Z等于执行zipinfo指令。

04. 参考示例

4.1 将压缩文件解压缩至当前目录下

[deng@localhost test]$ unzip aArchive:  a.zip extracting: a                       [deng@localhost test]$ lsa  a.zip  b  b.zip  c  d  e[deng@localhost test]$

4.2 解压缩时不覆盖原有文件

[deng@localhost test]$ lsa  a.zip  b  b.zip  c  d  e[deng@localhost test]$ unzip -n a.zip Archive:  a.zip[deng@localhost test]$

4.3 解压缩时覆盖原有文件

不必询问用户,unzip 执行后覆盖原有文件

[deng@localhost test]$ unzip -o a.zip Archive:  a.zip extracting: a                       [deng@localhost test]$

4.4 将压缩文件解压缩至指定目录下

[deng@localhost test]$ mkdir dir[deng@localhost test]$ unzip -n a.zip -d dir/Archive:  a.zip extracting: dir/a                   [deng@localhost test]$ tree dirdir└── a0 directories, 1 file[deng@localhost test]$

4.5 查看压缩文件目录(不解压)

[deng@localhost test]$ unzip -v a.zip Archive:  a.zip Length   Method    Size  Cmpr    Date    Time   CRC-32   Name--------  ------  ------- ---- ---------- ----- --------  ----       0  Stored        0   0% 07-24-2019 21:15 00000000  a--------          -------  ---                            -------       0                0   0%                            1 file[deng@localhost test]$

4.6 显示注释内容

[deng@localhost test]$ zip -z aa.zip a  adding: a (stored 0%)enter new zip file comment (end with .):神马程序员.  [deng@localhost test]$ unzip -z aa.zipArchive:  aa.zip神马程序员[deng@localhost test]$

4.7 显示文件中内容(不解压)

[deng@localhost test]$ unzip -l aa.zip Archive:  aa.zip神马程序员  Length      Date    Time    Name---------  ---------- -----   ----        0  07-24-2019 21:15   a---------                     -------        0                     1 file[deng@localhost test]$

4.8 用一个zipinfo命令来显示详细信息

[deng@localhost test]$ zipinfo a.zip Archive:  a.zipZip file size: 152 bytes, number of entries: 1-rw-rw-r--  3.0 unx        0 bx stor 19-Jul-24 21:15 a1 file, 0 bytes uncompressed, 0 bytes compressed:  0.0%[deng@localhost test]$

05. 附录

参考:

转载地址:https://dengjin.blog.csdn.net/article/details/97242795 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【Tools】Linux远程拷贝工具(WinSCP)
下一篇:【Linux】一步一步学Linux——zip命令(67)

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月27日 11时50分33秒