67

I have a large zip file and a limited amount of disk space. Can I determine how much space the expanded contents will take without decompressing the file?

1
  • 3
    For those who wonder how to do this with a 7z file: 7za l <your-7zip-file>. The fourth column is the uncompressed size.
    – galath
    Dec 4, 2017 at 6:56

2 Answers 2

75

You can do that by using the 'unzip' command with the "list" flag:

unzip -l yourzipfile.zip

That will output a listing of every file in the zip along with its size in bytes, and the final line will be the total decompressed size in bytes.

3
  • 5
    If we know that the archive contains a huge number of files, we can prevent a long output by using tail to only display the last 10 lines (or with -n you can specify the number of lines). Example: unzip -l yourzipfile.zip | tail -n 15
    – Byte Commander
    Nov 10, 2015 at 17:12
  • 7
    This command will return the size in bytes directly: unzip -l yourzipfile.zip | tail -1 | xargs | cut -d' ' -f1. And this will return the size in Megabytes: bc<<<"$(unzip -l yourzipfile.zip | tail -1 | xargs | cut -d' ' -f1)/1000/1000".
    – pLumo
    Jul 7, 2017 at 10:39
  • 1
    And then add numfmt to get a nicely formated number :) unzip -l file.zip | tail -1 | xargs | cut -d' ' -f1 | numfmt --to=iec-i --suffix=B
    – xeruf
    Dec 13, 2021 at 12:06
18

When you open a ZIP-file with the archive manager, it tells you the size of the contained files.

If you want to know how much all or some contained files are, just mark them (to mark all files: CTRL+A) and take a look at the bar on the bottom.enter image description here

1
  • 2
    Not so great. Maybe this archive manager does great, but I opened a 18 GB zip of some 120k JPEGs (MS COCO dataset, val2017.zip, IYKWIM), and the GUI manager was opening it forever, I killed it after a minute or two. unzip -l train2017.zip | tail works in 0.8 seconds. Jul 23, 2021 at 21:41

You must log in to answer this question.

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