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)?
To put multiple files into a bzip2 archive, first use tar to get them into one file, then compress that one file. Or since tar is "zip aware" you can use the -j flag to use bzip2 compression when you create the tar archive all as one step.
In order to zip multiple files using the zip command, you can simply append all your filenames. Alternatively, you can use a wildcard if you are able to group your files by extension.
In Unix and Unix-like operating systems (such as Linux), you can use the tar command (short for "tape archiving") to combine multiple files into a single archive file for easy storage and/or distribution.
bz2 files work natively and are used by default for saving all source code software program files. If, however, you are using Windows or Mac devices then you will need WinZip to compress, extract and archive tar. bz2 files.
You can simply concatenate many bz2 files into single bz2 file, like that:
$ cat file1.bz2 file2.bz2 file3.bz2 >resulting_file.bz2
bzip2
and other utilities like lbzip2
will be able to decompress the resulting file as expected.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With