The right answer if you only have the Sun version of tar is:
gzip -dc file.tar.gz | tar -tf -
as given by Riccardo Murri in a comment above. You can use that command on any version of Solaris since the dawn of day.
If you had GNU tar available then you of course wouldn't even be asking the question. I believe that on Solaris 11 that GNU tar is installed by default, however it will be called gtar
to distinguish it from the standard Sun version of tar.
If GNU tar for whatever reason is not installed on your Solaris 11 system then you can install it like this:
pkg install //solaris/archiver/gnu-tar
It is somewhat ironic that GNU tar is available now in the default install on Solaris 11 because it has become much less needed : it seems Oracle/Sun has update their own tar so that it now offers compression support (similar to GNU tar) and it can handle troublesome Linux tar files that would previously give an error if you tried to untar with Sun tar.
On Solaris 10 you can hope that your SysAdmin has been kind enough to install the contents of the "Solaris Companion CD" in which case you will find GNU tar in /opt/sfw/bin/gtar
. Unfortunately many Solaris SysAdmins take pride in deliberately not installing the packages from Sun (now Oracle) that make a Solaris system "GNU compatible" when they set up a host. Beats me why.
In any case : You should always have GNU tar on your system (at least on <Solaris11). Most open source packages are packaged with GNU tar and in some cases these cannot be untar'ed using Sun tar due to some differences in how symlinks are treated I believe. The opposite is never true, i.e. GNU tar can always untar a file that was created with Sun tar.
In your organisation: Make sure GNU tar is part of your default package for new Solaris hosts !
gzat -l
it displays only the tar archive in the compressed .gz archive. What I want is really in between: a list of all the files inside the tar archive. Never thought this would be that mind bending. – dr jerry Aug 05 '11 at 13:56gzip -dc file.tar.gz | tar -tv -f -
is the correct invocation; you need the-f -
to tell Solaris' tar to read data from STDIN (it's not the default as it is on many Linuxes), and you need to pass-d
and-c
to to gzip to decrompress to STDOUT. – Riccardo Murri Aug 05 '11 at 14:08tar
behavior, too. I'll update my answer to include the flags you mentioned. – Hank Gay Aug 05 '11 at 14:32