橘子味的心
标题:Linux shell zipinfo 命令

Linux shell zipinfo 命令用于列出压缩文件信息。

执行 zipinfo 指令可得知 zip 压缩文件的详细信息。

zipinfo 命令语法格式

zipinfo [-12hlmMstTvz] [压缩文件] [文件...] [-x <范本样式>]

[选项]:

选项 描述
-1 只列出文件名称
-2 此参数的效果和指定"-1"参数类似,但可搭配"-h","-t"和"-z"参数使用
-h 只列出压缩文件的文件名称
-l 此参数的效果和指定"-m"参数类似,但会列出原始文件的大小而非每个文件的压缩率
-m 此参数的效果和指定"-s"参数类似,但多会列出每个文件的压缩率
-M 若信息内容超过一个画面,则采用类似more指令的方式列出信息
-s 用类似执行"ls -l"指令的效果列出压缩文件内容
-t 只列出压缩文件内所包含的文件数目,压缩前后的文件大小及压缩率
-T 将压缩文件内每个文件的日期时间用年,月,日,时,分,秒的顺序列出
-v 详细显示压缩文件内每一个文件的信息
-x<范本样式> 不列出符合条件的文件的信息
-z 如果压缩文件内含有注释,就将注释显示出来


范例

我们先使用 zip 命令创建一个 demo.zip 的压缩文件

[root@localhost shell]# ls
demo.cpp  demo.sh  demo1.sh  demo2.sh  main.c
[root@localhost shell]# zip -q -r demo.zip .
[root@localhost shell]# ls
demo.cpp  demo.sh  demo.zip  demo1.sh  demo2.sh  main.c

1. 显示压缩文件 demo.zip 的信息

[root@localhost shell]# zipinfo cp.zip 
Archive:  demo.zip
Zip file size: 1116 bytes, number of entries: 5
-rw-r--r--  3.0 unx        0 bx stor 17-Sep-19 16:06 demo.cpp
-rw-r--r--  3.0 unx      122 tx defN 17-Sep-19 11:43 demo.sh
-rw-r--r--  3.0 unx       93 tx defN 17-Sep-19 11:43 demo1.sh
-rwxr-xr-x  3.0 unx      219 tx defN 17-Sep-19 11:43 demo2.sh
-rw-r--r--  3.0 unx        0 bx stor 17-Sep-19 16:06 main.c
5 files, 434 bytes uncompressed, 380 bytes compressed:  12.4%
[root@w3cschool.cc a]#

2. 显示压缩文件 demo.zip 中每个文件的信息

[root@w3cschool.cc a]# zipinfo -v demo.zip 
Archive:  demo.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                      1116 (000000000000045Ch)
  Actual end-cent-dir record offset:          1094 (0000000000000446h)
  Expected end-cent-dir record offset:        1094 (0000000000000446h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 5 entries.
  The central directory is 387 (0000000000000183h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 707 (00000000000002C3h).


Central directory entry #1:
---------------------------

  demo.cpp

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   1.0
  compression method:                             none (stored)
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2017 Sep 19 16:06:44
  file last modified on (UT extra field modtime): 2017 Sep 19 16:06:43 local
  file last modified on (UT extra field modtime): 2017 Sep 19 08:06:43 UTC
  32-bit CRC value (hex):                         00000000
  compressed size:                                0 bytes
  uncompressed size:                              0 bytes
  length of filename:                             8 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  Unix file attributes (100644 octal):            -rw-r--r--
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 f5 01 00 00 04 14 00 00 00.

  There is no file comment.

Central directory entry #2:
---------------------------

  demo.sh

  offset of local header from start of archive:   66
                                                  (0000000000000042h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2017 Sep 19 11:43:06
  file last modified on (UT extra field modtime): 2017 Sep 19 11:43:06 local
  file last modified on (UT extra field modtime): 2017 Sep 19 03:43:06 UTC
  32-bit CRC value (hex):                         e5c8a6a8
  compressed size:                                113 bytes
  uncompressed size:                              122 bytes
  length of filename:                             7 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             text
  Unix file attributes (100644 octal):            -rw-r--r--
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 f5 01 00 00 04 14 00 00 00.

  There is no file comment.

Central directory entry #3:
---------------------------

  demo1.sh

  offset of local header from start of archive:   244
                                                  (00000000000000F4h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2017 Sep 19 11:43:06
  file last modified on (UT extra field modtime): 2017 Sep 19 11:43:06 local
  file last modified on (UT extra field modtime): 2017 Sep 19 03:43:06 UTC
  32-bit CRC value (hex):                         5c5ce0fc
  compressed size:                                79 bytes
  uncompressed size:                              93 bytes
  length of filename:                             8 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             text
  Unix file attributes (100644 octal):            -rw-r--r--
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 f5 01 00 00 04 14 00 00 00.

  There is no file comment.

Central directory entry #4:
---------------------------

  demo2.sh

  offset of local header from start of archive:   389
                                                  (0000000000000185h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2017 Sep 19 11:43:06
  file last modified on (UT extra field modtime): 2017 Sep 19 11:43:06 local
  file last modified on (UT extra field modtime): 2017 Sep 19 03:43:06 UTC
  32-bit CRC value (hex):                         770ee340
  compressed size:                                188 bytes
  uncompressed size:                              219 bytes
  length of filename:                             8 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             text
  Unix file attributes (100755 octal):            -rwxr-xr-x
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 f5 01 00 00 04 14 00 00 00.

  There is no file comment.

Central directory entry #5:
---------------------------

  main.c

  offset of local header from start of archive:   643
                                                  (0000000000000283h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   1.0
  compression method:                             none (stored)
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2017 Sep 19 16:06:42
  file last modified on (UT extra field modtime): 2017 Sep 19 16:06:41 local
  file last modified on (UT extra field modtime): 2017 Sep 19 08:06:41 UTC
  32-bit CRC value (hex):                         00000000
  compressed size:                                0 bytes
  uncompressed size:                              0 bytes
  length of filename:                             6 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  Unix file attributes (100644 octal):            -rw-r--r--
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 f5 01 00 00 04 14 00 00 00.

  There is no file comment.

返回上一级

目录

分类