Linux zipinfo命令介绍
zipinfo是一个用于列出zip压缩文件的详细信息的命令,它可以显示压缩文件中每个文件的文件名,大小,压缩率,权限,加密状态,压缩方法,版本,操作系统等信息。zipinfo命令是unzip命令的一个链接,它们是同一个程序,但是在一些系统上,zipinfo可能在编译unzip时被省略了。zipinfo命令的输出格式类似于Unix的ls -l
和unzip -v
命令的结合。
Linux zipinfo命令适用的Linux版本
zipinfo命令适用于大多数Linux发行版,如Ubuntu, Debian, Fedora, CentOS等。如果某些Linux系统没有安装zipinfo命令,可以使用以下命令进行安装:
- 对于基于Debian的系统,如Ubuntu,可以使用
apt-get
命令:
[linux@bashcommandnotfound.cn ~]$ sudo apt-get install unzip
- 对于基于Red Hat的系统,如Fedora,CentOS 7,可以使用
yum
命令:
[linux@bashcommandnotfound.cn ~]$ sudo yum install unzip
- 对于CentOS 8,可以使用
dnf
命令:
[linux@bashcommandnotfound.cn ~]$ sudo dnf install unzip
Linux zipinfo命令的基本语法
zipinfo命令的基本语法如下:
zipinfo [选项] 压缩文件 [文件...] [-x 排除文件...]
其中,压缩文件是要查看的zip文件的路径,可以使用通配符来匹配多个文件。文件是压缩文件中要查看的文件的列表,也可以使用通配符或正则表达式来匹配多个文件。排除文件是压缩文件中要忽略的文件的列表,也可以使用通配符或正则表达式来匹配多个文件。
Linux zipinfo命令的常用选项说明
zipinfo命令的常用选项如下:
选项 | 说明 |
---|---|
-1 | 只列出文件名称,每行一个。这个选项排除所有其他选项,不显示头部,尾部和压缩文件的注释。这个选项适用于Unix脚本中。 |
-2 | 此参数的效果和指定"-1"参数类似,但可搭配"-h","-t"和"-z"参数使用。 |
-h | 只列出压缩文件的文件名称。 |
-l | 此参数的效果和指定"-m"参数类似,但会列出原始文件的大小而非每个文件的压缩率。 |
-m | 此参数的效果和指定"-s"参数类似,但多会列出每个文件的压缩率。 |
-M | 若信息内容超过一个画面,则采用类似more指令的方式列出信息。 |
-s | 用类似执行ls -l 指令的效果列出压缩文件内容。 |
-t | 只列出压缩文件内所包含的文件数目,压缩前后的文件大小及压缩率。 |
-T | 将压缩文件内每个文件的日期时间用年,月,日,时,分,秒的顺序列出。 |
-v | 详细显示压缩文件内每一个文件的信息。 |
-x | 不列出符合条件的文件的信息。 |
-z | 如果压缩文件内含有注释,就将注释显示出来。 |
Linux zipinfo命令的实例
以下是一些zipinfo命令的实例:
- 显示压缩文件的基本信息:
[linux@bashcommandnotfound.cn ~]$ zipinfo test.zip
Archive: test.zip
Zip file size: 486 bytes, number of entries: 4
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 a.c
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 b.c
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 c.c
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 e.c
4 files, 0 bytes uncompressed, 0 bytes compressed: 0.0%
- 显示压缩文件的详细信息:
[linux@bashcommandnotfound.cn ~]$ zipinfo -v test.zip
Archive: test.zip
There is no zipfile comment.
End-of-central-directory record:
-------------------------------
Actual offset of end-of-central-dir record: 464 (000001D0h)
Expected offset of end-of-central-dir record: 464 (000001D0h)
(based on the length of the central directory and its expected offset)
This zipfile constitutes the sole disk of a single-part archive; its
...
- 只列出压缩文件中的文件名:
[linux@bashcommandnotfound.cn ~]$ zipinfo -1 test.zip
a.c
b.c
c.c
e.c
- 只列出压缩文件的注释:
[linux@bashcommandnotfound.cn ~]$ zipinfo -z test.zip
This is a test zip file with some comments.
- 不列出压缩文件中以.c结尾的文件的信息:
[linux@bashcommandnotfound.cn ~]$ zipinfo -x *.c test.zip
Archive: test.zip
Zip file size: 486 bytes, number of entries: 4
4 files, 0 bytes uncompressed, 0 bytes compressed: 0.0%
- 用类似more指令的方式列出压缩文件的详细信息:
[linux@bashcommandnotfound.cn ~]$ zipinfo -M test.zip
Archive: test.zip
Zip file size: 486 bytes, number of entries: 4
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 a.c
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 b.c
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 c.c
-rw-r--r-- 2.3 unx 0 b- stor 10-May-23 18:54 e.c
4 files, 0 bytes uncompressed, 0 bytes compressed: 0.0%
--More--(0%)
Linux zipinfo命令的注意事项
- zipinfo命令只能查看zip格式的压缩文件,不能查看其他格式的压缩文件,如tar.gz, rar等。
- zipinfo命令不能修改压缩文件的内容,只能查看信息。如果要修改压缩文件的内容,可以使用zip或unzip命令。
- 如果系统没有安装zipinfo命令,会出现
bash: zipinfo: command not found
的错误提示,此时可以使用上面提到的方法进行安装。
评论区