Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to get the size that a tgz will take up once it's extracted, but without extracting it? I basically want

tar tzf file.tgz
with sizes beside them. I'm really looking for a total, so a solution that gives total size but not specific file sizes would work.

share|improve this question
up vote 12 down vote accepted

If it compressed using gzip compression, you can do something like:

gunzip -l filename.tar.gz

Since a tar is not compressed, that should give you the information you need.

share|improve this answer
Hm, to easy ;) +1 – Node May 19 '09 at 16:03

Hm I would prefer something like:

tar vtzf somefile.tar.gz |awk '{SUM += $3} END {print SUM}'
share|improve this answer
This is the closest to correct. Ideally you would round each $3 up to the filesystem block size. Variations in filesystems make this very difficult to solve in general. At least awk '{SUM+=($3>512?$3:512)}END{print SUM}' - but if you know the filesystem blocksize (if there is one), replace 512 with the actual blocksize. – carlito May 24 '09 at 0:18
zcat file.tgz | wc -c

Will give you the number of characters taken up by the uncompressed .tar file, which will be very close to correct.

share|improve this answer

You could uncompress the file and then pipe it into wc -c, which will count the number of bytes. Like so:

zcat myfile.tar.gz | wc -c
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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