From: Sang-Ho Yun on
Dear All,

I usually extract a .tgz file using the following tar command.

tar -zxvf foo.tgz

However, this would delete foo.tgz file.
Is there a way to preserve the foo.tgz file?

I tried -Pzxvf and it seemed to work, but -P is for the following (from man
tar)

-P, --absolute-names
don�t strip leading �/�s from file names

Am I doing it right?
Is there another way?

Thank you,
Sang-Ho

From: Stachu 'Dozzie' K. on
On 2010-05-23, Sang-Ho Yun <Sang-Ho.Yun(a)jpl.nasa.gov> wrote:
> Dear All,
>
> I usually extract a .tgz file using the following tar command.
>
> tar -zxvf foo.tgz
>
> However, this would delete foo.tgz file.

Erm. Have you actually tried doing this? Seems like you're confusing tar
and gzip.

> Is there a way to preserve the foo.tgz file?
>
> I tried -Pzxvf and it seemed to work, but -P is for the following (from man
> tar)
>
> -P, --absolute-names
> don¹t strip leading Œ/¹s from file names
>
> Am I doing it right?
> Is there another way?

--
Secunia non olet.
Stanislaw Klekot
From: pk on
Sang-Ho Yun wrote:

> Dear All,
>
> I usually extract a .tgz file using the following tar command.
>
> tar -zxvf foo.tgz
>
> However, this would delete foo.tgz file.

No it won't.
From: Kenny McCormack on
In article <3231745.ISyKVeVyVu(a)xkzjympik>, pk <pk(a)pk.invalid> wrote:
>Sang-Ho Yun wrote:
>
>> Dear All,
>>
>> I usually extract a .tgz file using the following tar command.
>>
>> tar -zxvf foo.tgz
>>
>> However, this would delete foo.tgz file.
>
>No it won't.

I wonder what 'tar' is aliased to...

--
(This discussion group is about C, ...)

Wrong. It is only OCCASIONALLY a discussion group
about C; mostly, like most "discussion" groups, it is
off-topic Rorsharch [sic] revelations of the childhood
traumas of the participants...

From: Arcege on
On May 23, 10:44 am, Sang-Ho Yun <Sang-Ho....(a)jpl.nasa.gov> wrote:
> Dear All,
>
> I usually extract a .tgz file using the following tar command.
>
> tar -zxvf foo.tgz
>
> However, this would delete foo.tgz file.
> Is there a way to preserve the foo.tgz file?
>
> I tried -Pzxvf and it seemed to work, but -P is for the following (from man
> tar)
>
>        -P, --absolute-names
>               don¹t strip leading Œ/¹s from file names
>
> Am I doing it right?
> Is there another way?
>
> Thank you,
> Sang-Ho

Sang-Ho,

Does 'foo.tgz' exist _inside_ the tarfile? Try running 'tar tzf
foo.tgz | grep -F foo.tgz'. If you get output, then the tarfile
contains an early copy of the tarfile while it was being generated.

You should never generate the tarfile in the same directory,
especially if you are including the current directory ('.').
Different implementations of tar would do different things, but I have
seen at least one version of tar end up in a circular loop of
repeatedly adding the same block to the end of the file: the last
block in foo.tgz. This would eventually fill up the filesystem.

And when you extract the files into the same directory as the tarfile,
it would overwrite the tarfile, of course.

If you "can't" be in the directory where you want to extract the
files, try using the 'C' option, which tells tar to change the
directory for you:
$ tar xzfC foo.tgz /path/to/extraction_directory file1 file2 subdirA
file3
But it is usually better to give the pathname to the tarfile since the
'C' is not available on all flavors of tar.

-Arcege