Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

To list an archive's contents I can do :

tar -tzvf mytarball.tar.gz

But this works for local files only. Can someone point out how to do it (if at all possible) for files over internet.

I tried it with a file

wget -q | tar -tzv

But gives

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now

So does tar work properly with streams for listing ? Are there any compression formats which allow this (without requiring to download the whole file) ?

share|improve this question

5 Answers 5

Your command would work, if you told wget to output the downloaded file to stdout rather than a file:

wget -q -O /dev/stdout http://… | tar -tzv

However, it will require downloading the whole file, at least for Tar and Zip archives. The Zip format puts its "directory" at the very end; meanwhile, Tar does not have a single directory and just has a linear stream of header+data pairs, so filenames are scattered everywhere.

(There certainly should be archive formats that can be listed this way, but I don't know the exact details of any other format out there.)

share|improve this answer

Edit: It is not possible to list the contents of a file over the internet, unless the server has an API or something to process the file and output the results. You should download the file locally and then process the file.

This should work.

wget -q && tar -tzvf git-1.8.0.tar.gz

A part from

List the contents of a tar file

$ tar -tvf file.tar

List the contents of a tar.gz file

$ tar -ztvf file.tar.gz

List the contents of a tar.bz2 file

$ tar -jtvf file.tar.bz2
share|improve this answer

Alternatively if you can run shell code on the remote host:

ssh remotehost 'tar -tzvf mytarball.tar.gz'

share|improve this answer
This has the benefit of requiring virtually no network transfer aside from the text listing of contents. – Ram Mar 10 '14 at 20:11

To redirect http data output from file to stdout you need to use -O switch, then you can grab it

wget -q -O - | tar -tzv

But still why you do this? Tar doesn't have file list, so like that you download full file to get file list, and one more time you will need to download full file to get wanted files. So if you plan to get some files from that tar.gz, better is to save it and delete it after.

The only good thing about this is to get file list for some indexing. For remote file list ZIP files are much better but still you can't download them using wget.

share|improve this answer

You can use:

wget -qO- | tar -xvz

The file will be downloaded, unpacked, and the screen will show the files.

But if you want make a file Request a and does not save it, use:

wget -q -O- | tar -xvz

enter image description here

share|improve this answer
What is the difference between your two command lines? I can’t find any. – erik Mar 10 '14 at 21:21

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.