The command below will create a .tar.gz with another archive in it which contains the actual files.

Is it possible to prevent the additional archive from being created and put all files directly inside the .tar.gz root folder?

GZIP=-9 tar -czf temp.tar.gz *.txt

  • 1
    You could have an uncompressed .tar file, but I'm not sure that is what you intend. Gzip, bzip, etc. do not combine several files into one, that's what tar is for. Feb 28, 2018 at 4:57

1 Answer 1


You are asking about a few things here

1 - 2 archives - a .gz (or .bz2) file, that contains a .tar file.

This is done because gzip/bzip2 only work on a single file. Once a file is compressed, the uncompressed version is removed. Uncompress it, and when done the compressed version is removed.

The tar command, (historically) didn't do compression on its own. But thanks to the open source goodness that they all 3 are, the shared libraries and some code let tar work with compression on the fly.

Perhaps the old Slackware/DOS 8.3 convention filename extension would help you think of it better - .tgz or .tbz

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .