thecep1
thecep1

Reputation: 13

How would I check the file size of the uncompressed tar file without extracting

I downloaded a 16GB tar file named "SetA.tar", but I would like to know how much space the uncompressed file would take up on my disk. How would I find that?

Upvotes: 1

Views: 3531

Answers (2)

OrangeDog
OrangeDog

Reputation: 38777

A tar file is not compressed. Therefore if SetA.tar is 16GB then it will use an additional 16GB if you extract everything.

Upvotes: 0

0stone0
0stone0

Reputation: 43983

.tar

Use tar -tvf SetA.tar to list all the files in the archive, to get the total size of the .tar pipe the result to to sum the total bytes;

tar -tvf SetA.tar | awk '{s+=$5} END{print (s/1024/1024), "MB"}'
  • -t List archive contents to stdout
  • -v Verbose
  • -f file path



.tar.gz

You could use gzip -l SetA.tar. Man page;

-l, --list This option displays information about the file's compressed and uncompressed size, ratio, uncompressed name. With the -v option, it also displays the compression method, CRC, date and time embedded in the file.

$ gzip -l sample.tar.gz
  compressed uncompressed  ratio uncompressed_name
       91700       522240  82.4% sample.tar

Upvotes: 1

Related Questions