How to get uncompressed size of a .tar.gz file without actually extracting it

Archives come in really handy when you want to share large amount of data over the Internet or through removable media (like USB drives). In Linux, the .tar.gz is one of the most used archive format.

While accessing the size of an archive is a cake walk, extracting it lets you know the original size of its contents. But what if you want to access the original size of an archive's contents without actually extracting the archive? In this article, we will explain how you can do this.

Please note that all examples/instructions mentioned here have been tested on Ubuntu 14.04 with Bash version 4.3.11.

Find actual size without uncompressing .tar.gz archive

To achieve this, you need to install the gzip command line tool (if it's not already there). The following command will let you do this:

sudo apt-get install gzip

Once installed, you can execute the tool with the -l command line option and name of the archive to see the size related details.

gzip -l [archive-name]

Following is an example:

gzip-l-in-action

That's it. As you can see, the figure listed under the 'uncompressed' column is what you want.

Here's what the tool's man page says about the -l option:

gzip-l-man-page

Leave a Comment