如何将 tar.bz2 转换为 .bz2?

如何将 tar.bz2 转换为 .bz2?

我有一个压缩文件 tar.bz2 ,我想将其转换为 .bz2 。有没有一个命令可以一次性完成此操作?

我尝试了以下但没有快乐!

 tar -xvjf US.tar.bz2
 US

 bzip2: Compressed file ends unexpectedly;
         perhaps it is corrupted?  *Possible* reason follows.
 bzip2: Inappropriate ioctl for device
         Input file = (stdin), output file = (stdout)

 It is possible that the compressed file(s) have become corrupted.
 You can use the -tvv option to test integrity of such files.

 You can use the `bzip2recover' program to attempt to recover
 data from undamaged sections of corrupted files.

 tar: Unexpected EOF in archive
 tar: Unexpected EOF in archive

聚苯乙烯

我也尝试了以下内容:

Bunzip2 -c < US.tar.bz2 | 压缩包gzip -c > us.bz2

产生:

bunzip2: Compressed file ends unexpectedly;
    perhaps it is corrupted?  *Possible* reason follows.
bunzip2: Inappropriate ioctl for device
    Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

答案1

tar就像一个 zip 文件,它存储了一堆其他文件,但不压缩它们。 bzip2压缩一个文件,但一次只能压缩一个文件。文件.tar.bz2可能表示一堆文件被放入tar并随后被压缩。首先,如果不涂柏油,你就无法将它们拉链在一起。

您的错误是因为您的.tar.bz2文件已损坏。请参阅下面的正常工作文件的示例。

$ ls
test_file.tar.bz2
$ tar xvjf test_file.tar.bz2 
test_file
$ ls
test_file  test_file.tar.bz2

编辑


在上面的例子中,tar.gz 中只有一个文件。如果您只想压缩该文件夹:

$ bzip2 test_file
$ ls
test_file.bz2

相关内容