On linux systems, GNU tar itself can do the job of listing out the files inside a tar.gz file without actually (g) unzipping it. But on AIX, that’s not the case. Cos, AIX tar doesn’t support the ‘z’ and ‘j’ flags that GNU tar does. And hence it cannot decompress a gzipped file. There’s a simple workaround though using a combination of gunzip and tar commands. Here it is
gunzip -c foo.tar.gz | tar -tvf –
-c Writes output to stdout
-t Lists files inside a tar file
-v Verbose mode. Spews out a detailed output if necessary.
-f File name
– When ‘-‘ is passed instead of a filename to tar, it reads from stdin
So, by connecting the stdout of gunzip to stdin of tar, we can list out the contents of a gzipped file without actually unzipped it and hence keeping the original copy as it is.