How do I list files inside compressed tar ball (gzip’d tar’d) archive?

Posted on in Categories last updated March 7, 2006

Tar command provides the option to list files inside compressed tar ball. However mtools includes command called lz which gunzips and shows a listing of a gzip’d tar’d archive without extracting files.

For example, display listing of file called backup.tar.gz type command:

$ lz backup.tar.gz

As you see lz provides a listing of a gzip’d tar’d archive, that is a tar archive compressed with the gzip command. It is not strictly necessary on Debian GNU/Linux (or other Linux/BSD/Solaris oses), because the GNU tar(1) program provides the same capability with the command:

$ tar -tzf backup.tar.gz

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 2 comments/add one below):

2 comment

  1. Thank you for great advice. I found that lz works well with wildcards, but tar -tzf does not.
    For example: tar -tzf *.tar.gz produces the following errors:
    tar: file_1.tar.gz: Not found in archive
    tar: file_2.tar.gz: Not found in archive

    tar: file_n.tar.gz: Not found in archive
    tar: Error exit delayed from previous errors

    lz *.tar.gz, on the other hand, works great!

Leave a Comment