Show tar.gz files but tar.gz is already inside a tar file

aixgziptar

I want to see a tar.gz files that are inside a tar file.

So I have a tar file that has a tar.gz file inside and I want to see the tar.gz files without extraction my tar and my tar.gz.

So to explain more, inside my tar I have a tar.gz, File.tar -> File.tar.gz. so I need to see the files inside my tar.gz but my tar.gz is already inside my tar, and that without extracting my tar and also my tar.gz.

I tried this but doesn't work :
tar -xvf File.tar File2.tar.gz | gtar -ztvf –

Can you help me with this?

Best Answer

You'll need to run tar -tf /path/to/file.tar.gz, or tar -tzf /path/to/file.tar.gz.

As far as I've seen, you should avoid using -tf, and prefer -tzf: at least on BSD systems, forgetting the z gives:

tar: input compressed with gzip; use the -z option to decompress it

Following up on your comment, say you want to list the content of an archive inside an archive, ... Try this:

tar -zxOf /path/to/parent/archive.tar.gz path/to/packed/archive.tar.gz | tar -ztf -

With path/to/packed/archive.tar.gz, the path of your archive inside /path/to/parent/archive.tar.gz.

Related Question