13

Before using tar to extract a .tar.gz archive, it is possible to get an estimate of how large the extracted files are in total?

1
  • Try gzip -l archive.tar.gz
    – Costas
    Nov 7, 2014 at 19:52

1 Answer 1

22

For gzip:

$ gzip -l binutils-2.24.tar.gz
         compressed        uncompressed  ratio uncompressed_name
           30809913           186997248  83.5% binutils-2.24.tar

Now you see a compressed and an uncompressed size of the content.

Or alternatively use that command:

$ zcat binutils-2.24.tar.gz | wc --bytes
186997248

For bzip2, there is bzcat:

$ bzcat binutils-2.24.tar.bz2 | wc -c
186997248

For rar, use:

$ unrar l archive.rar
...
    1        465769002 102749558  22%

In the last line of the output there is the original size in bytes (the second digit).

For zip, use

$ unzip -l archive.zip
...
700136                     4 files

Also the last line (the first digit)

4
  • Thanks. WHat if it is other common types' compression files, e.g. .bz, .rar, .zip, ...?
    – Tim
    Nov 7, 2014 at 20:07
  • @Tim see my edit
    – chaos
    Nov 7, 2014 at 20:20
  • Note that the methods which use -l or l are much more efficient than the *cat methods. The former methods simply read the file size data from the archive header, the later methods extract the entire archive contents.
    – PM 2Ring
    Nov 8, 2014 at 8:46
  • For xz xz -l file.xz
    – Jore
    Aug 31, 2023 at 16:14

You must log in to answer this question.

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