Linux 如何在不解压缩的情况下列出 zip 存档中的文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15517731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 22:29:25  来源:igfitidea点击:

How can I list the files in a zip archive without decompressing it?

linuxbashshellunixzip

提问by einpoklum

How can I get the equivalent of an lsof a .zip file (not gzip), without decompressing it, from the command shell? That is, how can I list the different files compressed within my .zip archive?

如何ls在不解压缩的情况下从命令 shell获得相当于.zip 文件(不是 gzip)的文件?也就是说,如何列出 .zip 存档中压缩的不同文件?

采纳答案by Miklos Aubert

Perreal's answeris right, but I recommend installing atool(look for it in your distribution's package manager). Then, for any kind of archive file, bzip2, gzip, tar... you have just one command to remember :

Perreal 的回答是正确的,但我建议安装atool(在您的发行版的包管理器中查找)。然后,对于任何类型的存档文件,bzip2、gzip、tar...您只需记住一个命令:

als archive_name

回答by perreal

Use unzip with-loption:

使用带有-l选项的解压缩

unzip -l file.zip

回答by Xavier S.

You can also use "zmore archive_name". It will list archive and it content.

您也可以使用“zmore archive_name”。它将列出存档及其内容。

回答by papalagi

Use lesspipein Debian/Ubuntu, it also can list many other archive types:

使用lesspipe的是Debian / Ubuntu的,它也可以列出许多其他归档类型:

     *.arj
     *.tar.bz2
     *.bz
     *.bz2
     *.deb, *.udeb
     *.doc
     *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
     *.iso, *.raw, *.bin
     *.lha, *.lzh
     *.pdf
     *.rar, *.r[0-9][0-9]
     *.rpm
     *.tar.gz, *.tgz, *.tar.z, *.tar.dz
     *.gz, *.z, *.dz
     *.tar
     *.jar, *.war, *.xpi, *.zip
     *.zoo
     *.arj
     *.tar.bz2
     *.bz
     *.bz2
     *.deb, *.udeb
     *.doc
     *.gif, *.jpeg, *.jpg, *.pcd, *.png, *.tga, *.tiff, *.tif
     *.iso, *.raw, *.bin
     *.lha, *.lzh
     *.pdf
     *.rar, *.r[0-9][0-9]
     *.rpm
     *.tar.gz, *.tgz, *.tar.z, *.tar.dz
     *.gz, *.z, *.dz
     *.tar
     *.jar, *.war, *.xpi, *.zip
     *.zoo

Usage:

用法:

lesspipe file.zip

reference

参考

回答by user7531546

To list/view the contents of a compressed file on a Linux host without uncompressing it (and where GZIP is installed), use the "zcat" command.

要在 Linux 主机上列出/查看压缩文件的内容而不解压缩它(以及安装 GZIP 的位置),请使用“zcat”命令。

zcat compressedfilename |more

zcat 压缩文件名 |more

回答by mzalazar

zipinfo -1 filename.zip

It returns only filenames, and no more, example (response):

它只返回文件名,不再返回示例(响应):

listing.html
my_data.csv
super.txt

回答by computingfreak

The lessutility is capable of peeking into a ziparchive.

less实用程序能够查看zip档案。

Less comes bundled with Unix and there is no need to install als. The output is scrollable (paged) and does not log things to the terminal (unlike unzip -l mentioned in the other answer).

Less 与 Unix 捆绑在一起,无需安装 als。输出是可滚动的(分页)并且不会将内容记录到终端(与其他答案中提到的 unzip -l 不同)。

As per https://superuser.com/a/216675/249975,

根据https://superuser.com/a/216675/249975

so simply use less filename.zip

所以简单地使用 less filename.zip

cheers!

干杯!

回答by Javeed Shakeel

To view the contents of a zipped file without unzip by using this command

使用此命令查看不解压的压缩文件的内容

unzip -l file.zip

Gor tar files we can use

我们可以使用的 Gor tar 文件

zcat <archived-file>