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

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.

ADVERTISEMENTS

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

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • Frank Sep 16, 2010 @ 13:46

    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!

  • Jass Oct 31, 2011 @ 10:25

    I tried the comment in Solaris. It’s not working. Can anyone help me?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.