首页 > 解决方案 > 列出 zip 子目录中的文件

问题描述

要列出电子表格(xlsx)文件中的所有文件,我可以这样做:

$ unzip -l /Users/david/Desktop/myspreadsheet.xlsx
      698  01-01-1980 00:00   xl/_rels/workbook.xml.rels
1415625191  01-01-1980 00:00   xl/worksheets/sheet1.xml
     6798  01-01-1980 00:00   xl/theme/theme1.xml
     2315  01-01-1980 00:00   xl/styles.xml
   779218  01-01-1980 00:00   xl/sharedStrings.xml
      322  01-01-1980 00:00   xl/worksheets/_rels/sheet1.xml.rels
     9840  01-01-1980 00:00   xl/printerSettings/printerSettings1.bin
      640  01-01-1980 00:00   docProps/core.xml
      797  01-01-1980 00:00   docProps/app.xml

从这里我们可以看到电子表格有一张 - xl/worksheets/sheet1.xml。有没有办法只查看xl/worksheets/文件夹的 zip 内容?例如,执行以下操作:

$ unzip -l /Users/david/Desktop/myspreadsheet.xlsx xl/worksheets

我能从man那里找到的最多的是:

   -l     list archive files (short format).  The names, uncompressed file sizes and modification dates  and
          times of the specified files are printed, along with totals for all files specified.  If UnZip was
          compiled with OS2_EAS defined, the -l option also lists columns  for  the  sizes  of  stored  OS/2
          extended  attributes (EAs) and OS/2 access control lists (ACLs).  In addition, the zipfile comment
          and individual file comments (if any) are displayed.  If a file was archived  from  a  single-case
          file  system  (for example, the old MS-DOS FAT file system) and the -L option was given, the file-
          name is converted to lowercase and is prefixed with a caret (^).

但似乎还有很多其他选择。有没有办法做到以上几点?

标签: excellinuxzipunzip

解决方案


推荐阅读