Rohith
Rohith

Reputation: 1167

combining gunzip and tar commands in Solaris and AIX

I am running the below command to untar a file in Solaris and AIX:

# gunzip /opt/myfile.tar.gz | tar -xvf-

but I'm getting this error:

tar: Unexpected end-of-file while reading from the storage media.

What do I need to fix?

Upvotes: 0

Views: 2063

Answers (2)

mauro
mauro

Reputation: 5950

I think something like this should work but I I don't have a Solaris system to test it...

gzip -dc /opt/myfile.tar.gz | tar xvf -

Upvotes: 1

c0t0d0s0
c0t0d0s0

Reputation: 146

Why should this work? The default behaviour of gunzip unpacks the file in place, substitutes the packed file with the unpacked one and you didn't specified the nescessary command to put the uncompressed datastream to stdout. So the tar command doesn't receive anything through the pipe to process and so you get the errormessage you have seen.

This will work:

gunzip -c ../myfile.tar.gz | tar -xfv -

This command line was tested on a Solaris 11.3 ... older variants of Solaris may need a different sorting of the command line like

gunzip -c ../myfile.tar.gz | tar -xvf -

Upvotes: 2

Related Questions