0

What's the easiest way to use the "du" command on zip files? I'm sure this is quite a common use case, but I couldn't find anything using Google.

I'd rather not resort to mounting the zip file and running du as if it was an exploded directory.

Sridhar Sarnobat
  • 25,183
  • 12
  • 93
  • 106

1 Answers1

1

I never heard of du working for zip files, probably you should use gunzip for that purpose - http://www.abeel.be/content/determine-uncompressed-size-gzip-file

I think you should better ask on http://superuser.com

Command for listing .zip archive is:

gunzip -l file.zip

For other formats I'll quote nice example from here:

Task: List the contents of a tar file

Use the following command: $ tar -tvf file.tar

Task: List the contents of a tar.gz file

Use the following command: $ tar -ztvf file.tar.gz

Task: List the contents of a tar.bz2 file

Use the following command: $ tar -jtvf file.tar.bz2

David Jashi
  • 4,490
  • 1
  • 21
  • 26
  • Thanks David. It seems like each unzipping program has its own listing mechanism which can display the size at the beginning of the line (gunzip and unzip do, I can't see anything for tar without more experimenting). It would be nice if there was a command that makes it easy, like the title of this thread. – Sridhar Sarnobat Jun 28 '13 at 17:27
  • @Sridhar-Sarnobat Wait a minute, so you have tar inside your zip then? Nevertheless I'll update answer with some links and example to make it simpler, but you should really consider reading `man gunzip` – David Jashi Jun 28 '13 at 18:45
  • No I don't have a tar inside a zip. What I meant is that the output of unzip -l and gunzip -l begins with the file size (like du) but tar does not, so you can't sort by size. Though the sort command can get around this. http://www.linuxquestions.org/questions/linux-software-2/show-biggest-files-in-tar-archive-368486/ . Your answer has enough information to make it work. Thanks. – Sridhar Sarnobat Jun 28 '13 at 22:05