How can I untar a tar.bz file in unix?

妖精的绣舞 提交于 2019-12-02 21:51:42

use the -j option of tar.

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

According to the man pages for 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.

Based on this, I'm guessing that '.bz' is considered a valid suffix for bzip2 compressed files. Also, keep in mind that the original file name was probably generated by hand, something like this:

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

Rather than doing this:

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

Which would force the filename to be archive.tar.bz2.

Unless the file that you're unpacking is older than, say 1998 (bzip2 was released in 1996), I'm guessing that you're actually looking at a bz2 file.

If you're interested in the history of bzip vs bzip2 and the technical differences between the two, there's good discussion on the Wikipedia Bzip2 page as well as the archive of the bzip2 home page. The latter includes a link to the original bzip source, which is not compatible with bzip2 because the it would require patent encumbered code to de-compress files compressed with the original bzip.

The file types differ by magic number, bzip2 uses BZh, the original bzip uses BZ0.

If it's really an old bzip 1 archive, try:

bunzip archive.tar.bz

and you'll have a standard tar file. Otherwise, it's the same as with .tar.bz2 files.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!