I have a 32GB .tar.gz archive and I'd like to know the size of the files if I unpack this compressed archive. I'd like to avoid unpacking the archive first and than use e.g. du
.
Is it also possible to find out the size of the contained files without unpacking the compressed archive (on a Linux and/or MacOSX system)?
For another archive I know, that it also contains .tar.gz files. Is it also possible to calculate the size of the unpacked archives that are contained within an archive? (for example by setting a level to which the "unpacking" should be simulated?)
Best Answer
Sure. Just use
-tv
to list the contents with their sizes. E.g.If you want to add up the sizes (like
du
), you can useawk
:For an imbedded
.tar.gz
file, you would need to do those individually when you find them by sending them tostdout
with-O
:You can write a script to find those in the
-tv
output and then extract them, and even do it recursively. I will leave that as an exercise for the reader.Note, these options are for GNU tar, which is what is on both Linux and Mac OS X. The options for BSD tar may be different.