Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Does anyone know how to list the contents of a .tar.gz, without first uncompressing? using gzip only reports back the foo.tar, and tar doesn't recognise foo.tar.gz as a valid tar archive.
Can this be done? It could save me a lot of time uncompressing big tar's full of data to find the right file.
Using just the -t option wont show the contents of tar.gz or tar.bz2 archives. You have to filter them further thru gzip or bzip. For example, to see the contents you will do:
for tar file: tar -tvf foo.tar
for gzip file: tar -ztvf foo.tar.gz
for bz file: tar -jtvf foo.tar.bz
Midnight Commander will let you browse the contents of an archive as if it were a directory (in a sense...it actually just extracts it to a temp directory).
Originally posted by bhaskie Using just the -t option wont show the contents of tar.gz or tar.bz2 archives. You have to filter them further thru gzip or bzip. For example, to see the contents you will do:
for tar file: tar -tvf foo.tar
for gzip file: tar -ztvf foo.tar.gz
for bz file: tar -jtvf foo.tar.bz
Check it out for yourself!
...
This will only show junk on the console. He wants to display the list of files in the tarball. Not the binary contents!
Please dont confuse other members. You concatenated two of my posts showing that I am contradicting myself!
I wasnt contradicting my original post. That's the simplest way to do it. I was saying doing a
Code:
less foo.tar.gz
will throw junk on the screen.
Of course, mc is very convenient to browse thru tarballs. I do agree with u on that. But doing a
Code:
tar -ztvf foo.tar.gz
or
Code:
tar -jtvf foo.tar.bz2
displays the same without the need of installing mc.
Originally posted by bhaskie Please dont confuse other members. You concatenated two of my posts showing that I am contradicting myself!
Sorry...I was just being silly. You pointed out the shortcomings of the other two suggestions, but no flaw in mine....so naturally I'd assumed that I won
Originally posted by mikshaw Sorry...I was just being silly. You pointed out the shortcomings of the other two suggestions, but no flaw in mine....so naturally I'd assumed that I won
Hey relax! I get your point.It was just that someone reading the post will get the idea that the command I suggested will throw junk at the screen. I didnt want anyone to get a wrong idea. That's all.
Now that you want me to prove that my method is subtler and simpler than yours, here's my answer!
MC (midnight commander) creates a temp directory in /tmp as /tmp/mc-root (assuming you are root). So if you click on a tarball in mc, it extracts the tarball to that temp directory. Thus you get to view the contents of the archive.
Now that is ok for a small archive. Imagine what's goin to happen when you click on the kernel sources tarball or some other archive >100MB. Thats goin to take a really long time. You can click on a tarball in MC and open a console, check in /tmp/mc-<username>/<som_folder>/some_file. Do a "file foo" on that file and it will show a tar archive.
Also, this defeats the main purpose of this thread.
Quote:
Originally posted by leontini
How to list contents of a .tar.gz without unzip? ( post #1)
Hey all,
Does anyone know how to list the contents of a .tar.gz, without first uncompressing? using gzip only reports back the foo.tar, and tar doesn't recognise foo.tar.gz as a valid tar archive.
Can this be done? It could save me a lot of time uncompressing big tar's full of data to find the right file.
The guy asked a method to view contents of an archive without decompressing. MC no doubt is good but defeats the purpose! Why not keep it simple?
P.S. I am not trying to start a war here. Just helping out fellow linuxers.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.