decompress and compress to another format on the fly

1k views Asked by At

I have a big gzip file that I need to change it to bzip2.

Obvious way is to 1) decompress the file in memory, 2) write it on disk, 3) read the file again and compress it to bzip2 and write into disk.

Now I'm wondering if it's possible to avoid the middle phase (writing into disk) and do the decompression and compression in memory and write the final result in disk?

1

There are 1 answers

0
nbari On BEST ANSWER

You could decompress to stdout and then pipe to bzip2, something like this should work:

gunzip -c file.gz | bzip2 > file.bz2