Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 08 Feb 2015 12:57:20 -0500
From:      Lowell Gilbert <freebsd-questions-local@be-well.ilk.org>
To:        Manish Jain <bourne.identity@hotmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: why does tar archive directory differently based on command line?
Message-ID:  <44bnl4qoan.fsf@lowell-desk.lan>
In-Reply-To: <BLU436-SMTP2585638FB0568F935D69E10F6260@phx.gbl> (Manish Jain's message of "Sun, 8 Feb 2015 13:23:12 %2B0530")
References:  <BLU436-SMTP2585638FB0568F935D69E10F6260@phx.gbl>

next in thread | previous in thread | raw e-mail | index | archive | help
Manish Jain <bourne.identity@hotmail.com> writes:

> I am having problems trying to understand why does tar archive
> differently with the following 2 commands, presuming xyz is a
> sub-directory :
>
> tar -c -f - ./xyz | gzip > xyz.tar.gz//xyz nested one level under . and ..
> tar -c -f - xyz   | gzip > xyz.tar.gz//no . or ..
>
> With the first invocation, I get a top-level nesting that just has . and ..
> With the second, I get a top-level nesting that has xyz, which is much
> preferable

Right. tar(1) stores the path to the file. This is essential
functionality, so if you want a particular path stored, you
provide that path in the way you invoke tar in the first place.

> The first invocation leads to an absurdity that you have to cd into
> . (sounds recursively impossible) to actually get to xyz

It's neither absurd nor recursively impossible (whatever that
means). If you were planning to extract the tar file from one
level higher up the destination tree, it would be exactly what
you would want.

Perhaps you would be happier with a GUI application for
creating your tar files. There are many fine choices, and you
probably have one (or more) already installed on your system.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44bnl4qoan.fsf>