如何在unix中解压缩tar.bz文件?

Tim*_*Tim 32 unix linux bash extract tar

我发现有很多页面说明如何解压缩tar.bz2文件,但是如何解压tar.bz文件呢?

Shi*_*dim 58

使用-j选项tar.

tar -xjf /path/to/archive.tar.bz
Run Code Online (Sandbox Code Playgroud)

  • 我认为最好不要离开`-`.只需`tar xjf/path/to/archive.tar.bz`即可. (4认同)

Bar*_*den 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.
Run Code Online (Sandbox Code Playgroud)

基于此,我猜测'.bz'被认为是bzip2压缩文件的有效后缀.另外,请记住原始文件名可能是手工生成的,如下所示:

tar jcf archive.tar.bz /path/to/files
Run Code Online (Sandbox Code Playgroud)

而不是这样做:

tar cf archive.tar /path/to/files && bzip2 archive.tar
Run Code Online (Sandbox Code Playgroud)

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

除非您解压缩的文件比1998年更早(bzip2于1996年发布),我猜你实际上在查看bz2文件.

如果您对bzip vs bzip2的历史以及两者之间的技术差异感兴趣,可以在Wikipedia Bzip2页面以及bzip2主页的存档上进行讨论.后者包括到原始bzip源的链接,它与bzip2 兼容,因为它需要专利保护代码来解压缩用原始bzip压缩的文件.

文件类型因幻数而异,bzip2使用BZh,原始bzip使用BZ0.