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

后端 未结 3 677
陌清茗
陌清茗 2021-02-03 20:25

I\'ve found tons of pages saying how to untar tar.bz2 files, but how would one untar a tar.bz file?

3条回答
  •  一整个雨季
    2021-02-03 20:34

    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.

提交回复
热议问题