I am reading an offline document of bzip2 and I am told that I can compress multiple files into one single archive using bzip2 like this:

bzip2 finalArchive.bz2 file1 file2 file2

But when I try this I get

Can't open input file finalArchive.bz2: No such file or directory.

and I'm getting those 3 files compressed individually as file1.gz2 file2.gz2 and file3.gz2 and I also know that I could cat them into one single file but I want to be ab;e to do that using one single command.

I am able to do just that using zip:

zip finalArchive.zip file1 file2 file3

and I'm getting the expected finalArchive.zip file

4 Answers 4


Both bzip2 and gzip work on a single file. When that file is compressed, the uncompressed version is removed. When extracting, the opposite takes place.

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.

  • 1
    So you are saying that there is no such thing as this command: bzip2 finalArchive.bz2 file1 file2 file3?
    – Cat Hariss
    Jan 22, 2018 at 0:19

The most common Unix compression utilities (gzip, bzip2, xz) all operate on single files, and the standard way to make a multi-file archive is to combine them with tar.

You get the Can't open input file finalArchive.bz2: No such file or directory. error because bzip2 thinks you want to compress a file called finalArchive.bz2, which of course doesn't exist.

To accomplish what you want, use this command:

tar -cjf finalArchive.tar.bz2 file1 file2 file3

where the j option tells tar to use bzip2 to compress the tar archive. See the relevant section in the tar manual for more about this.

If you are using a very old version of tar without compression support, you would need do the compression step manually:

tar -cf - file1 file2 file3 | bzip2 -c > finalArchive.tar.bz2

Either bzip2 and gzip use file concatenation. That means bzip2 files will result in files.bz2. It's possible to concatenate multiple files like:

bzip2 -c file1 > files.bz2
bzip2 -c file2 >> files.bz2

However this is almost the same of doing cat file1 file2 > files You can check the uncompressed result of the concatenation to the stdout by using the bzcat command, e.g:
bzcat files.bz2

So the files.bz2 will still being a single file at the end. To be clear on that, if you extract the files.bz2 like:

bunzip files.bz2

The result will be just a single file named files, and it's content will be the concatenation of the file1 and file2.

Multiple files need to be packed with the tar command like tar -cvjf files.tbz file1 file2
Where the -j here is equivalent wrapper flag from the tar command to add the bzip compression.


Remove finalArchive.zip just input the list of files. Example screenshot below:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.