如何在Unix系统中解压缩.tar.bz文件?

35

我发现很多网页都讲述了如何解压tar.bz2文件,但是如何解压tar.bz文件呢?


5
我认为它的运作方式与.tar.bz2文件相同。 - Pekka
3个回答

62

使用tar命令的-j选项。

tar -xjf /path/to/archive.tar.bz

4
我认为最好不要带上“-”。只需要输入tar xjf /path/to/archive.tar.bz即可。 - Scott Stafford

7

根据bzip2的手册页面

   If  the  file  does  not end in one of the recognised endings, .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot guess the
   name of the original file, and uses the original name with .out appended.

根据这个,我猜测“.bz”被认为是bzip2压缩文件的有效后缀。同时,请记住原始文件名可能是手动生成的,类似于这样:

tar jcf archive.tar.bz /path/to/files

不要这样做:

tar cf archive.tar /path/to/files && bzip2 archive.tar

这将强制文件名为archive.tar.bz2。

除非您解压的文件比1998年更老(bzip2发布于1996年),否则我猜您实际上是在查看bz2文件。

如果您对bzip与bzip2的历史以及两者之间的技术差异感兴趣,可以在维基百科Bzip2页面bzip2主页档案中找到很好的讨论。后者包括指向原始bzip源代码的链接,该代码与bzip2不兼容,因为解压使用原始bzip压缩的文件需要专利受限代码。

文件类型由魔数区分,bzip2使用BZh,而原始的bzip使用BZ0。


3
如果确实是一个旧的bzip1存档文件,请尝试:
bunzip archive.tar.bz

你会得到一个标准的tar文件。 否则,和.tar.bz2文件一样。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接