3
1
Is there a way to extract a single file from a tar file to a specific directory?
In fact, I am dealing with a .tgz
file so, I am attempting something like this :
gunzip -c mytargzfile.tgz | tar xvf - path/to/myfile -C /tmp
In order to extract a file entry called path/to/myfile
in mytargzfile.tgz
to /tmp
directory.
But this command fails as tar complains saying it can not find file named -C
and /tmp
in the archive. I tried switching -C
option before xvf
and it did not help either.
Note that I am using AIX, and KSH
can't you just use the -z file on tar and skip the gunzip step? -z tells tar to treat it as a compressed archive. So you'd have
tar -xzvf mytargzfile.tgz -T path/to/myfile /tmp
– peelman – 2010-10-15T17:37:47.590the version of tar that comes standard on AIX does not have the -z option. – ring bearer – 2010-10-15T18:56:24.730