Commands.page Logo

Check Total Size of Files in Ubuntu Compressed Archive

Managing storage on Ubuntu often requires knowing how much data resides inside compressed files before extracting them. This article provides the specific terminal commands needed to view the total uncompressed size of contents within ZIP and TAR archives directly from the command line.

Checking ZIP Archive Size

For ZIP files, the unzip utility provides a built-in list function that calculates the total size automatically. Run the following command in your terminal:

unzip -l filename.zip

The output will list every file inside the archive and display a total sum at the bottom of the list labeled as “Total.”

Checking TAR Archive Size

TAR archives do not display a total sum by default, so you must combine the tar command with awk to calculate the size. Use this command for .tar or .tar.gz files:

tar -tvf filename.tar.gz | awk '{total+=$3} END {print total}'

This command lists the archive contents and sums the third column, which represents the file size, giving you the total uncompressed data size.