How to view/list the files in an archive(tar or zip) without extracting/decompressing it
Many a times, its better to view what's in the archive before extracting it. Sometimes the stuff compressed together is useless and extracting it might be just a waste of time and energy. Here we will consider both tar and zipped files and will list out the files bundled inside without fully extracting it.
For graphical environments, one can easily view the files inside by using an archive manager, eg. file-roller in GNOME.
For Consoles
For tar files, we can use the "-t" option to state the contents of the file. This options applies to both zip and bzip formats.
[shredder12]$ tar -tf file.tar
or
[shredder12]$ tar -tf file.tar.gz
or
[shredder12]$ tar -tf file.tar.bz2
In case of files archived using gzip, we can use the "-l" option of unzip command.
[shredder12]$ unzip -l file.zip



























2 Comments
Thanks astralia. I never even tried opening an archived file with vim thinking that it would just show garbage values because of its random binary content. Vim is indeed smart :).
Post new comment