How to convert a tar archive.gz to tar.bz2 format?

There is an archive in the form of tar.gz, and it needs to be fed to a program that requires the tar.bz2 format as input. How do I perform the conversion in a *nix-like environment?

Author: AntonioK, 2016-02-03

1 answers

In this task, we can use the magic of standard streams - you can unpack a gzip archive on the fly and repack it to a bzip2 archive without creating an intermediate file on the disk. The command will look like this:

gunzip < file.tar.gz | bzip2 > file.tar.bz2

If file.tar.gz You don't need it anymore after repacking, you need to explicitly delete it with a separate command.

For maximum (but less fast) compression, you can write bzip2 -9 instead of bzip2.

 1
Author: AntonioK, 2016-02-03 09:56:15