如何將 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

相關內容