Search code examples
unixcompressionbzip2

Possible to combine several bz2 archives into one?


I have several (27) huge (several GB each) bz2 archive files that I need combined into one bz2 archive. Uncompressing them and then creating a new archive from what was just uncompressed is not an option for me, since compressed, all 27 files add up to about 100GB, and uncompressed it's about 5-6TB (yes that's TERAbytes lol).

Can this be done with some sort of script, or is there even another compression format that allows for this to be done (easier)?


Solution

  • If you're willing to burn a few days of CPU, here's one solution with the magical pipe facility of modern UNIX(R) operating systems:

    bzip2 -dc file*.bz2 | bzip2 >resulting_file.bz2
    

    ... actually, grab lbzip2 version 2.0, and do the same, except with lbzip2, on a multicore:

    lbzip2 -dc file*.bz2 | lbzip2 >resulting_file.bz2