无需解压仅 1 级即可读取压缩文件的内容?

无需解压仅 1 级即可读取压缩文件的内容?

unzip 选项 -t 和 -l 列出整个 zip,甚至子目录。unzip 是否有选项可以只读取 1 级内容?它应该列出 zip 的直接内容。它不应该列出的内容子目录。

我读过了这个问题并且它不是它的重复品。

答案1

根据手册页:

[-x xfile(s)]
   An  optional  list of archive members to be excluded from process‐
   ing.  Since wildcard characters  normally  match  (`/')  directory
   separators  (for exceptions see the option -W), this option may be
   used to exclude any files that are in subdirectories.   For  exam‐
   ple,  ``unzip foo *.[ch] -x */*'' would extract all C source files
   in the main directory, but none in  any  subdirectories.   Without
   the  -x  option,  all C source files in all directories within the
   zipfile would be extracted.

所以答案是:

unzip -l <zipfile> -x '*/*'

相关内容