简体   繁体   English

如何从 bz2 存档中获取文件列表(ls 命令)?

[英]How to get the list of files (ls command) from bz2 archive?

.bz2类型的存档文件( .bz2压缩存档)获取文件列表(如ls )的 Unix bash 命令是什么?

First bzip2 , gzip , etc compress only one file.首先bzip2gzip等只压缩一个文件。 So probably you have compressed tar file.所以可能你有压缩的tar文件。 To list the files you need command like:要列出您需要的文件,请使用以下命令:

tar tjvf file.bz2

This command uncompress the archive and test the content of tar .此命令解压缩存档并测试tar的内容。

Note that bzip2 compresses each file, and a simple .bz2 file always contains a single file of the same name with the ".bz2" part stripped off.请注意,bzip2 会压缩每个文件,一个简单的 .bz2 文件始终包含一个同名文件,其中“.bz2”部分被剥离。 When using bzip2 to compress a file, there is no option to specify a different name, the original name is used and .bz2 appended.使用 bzip2 压缩文件时,没有指定不同名称的选项,使用原始名称并附加 .bz2。 So there are no files, only 1 file.所以没有文件,只有1个文件。 If that file is a tar archive, it can contain many files, and the whole contents of the .tar.bz2 file can be listed with "tar tf file.tar.bz2" without unpacking the archive.如果该文件是 tar 存档,则它可以包含许多文件,并且 .tar.bz2 文件的全部内容可以用“tar tf file.tar.bz2”列出,而无需解压存档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM