How to list files inside a tar.gz file on AIX?

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s