Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Sep 2003 13:40:00 +0200 (CEST)
From:      Konrad Heuer <kheuer2@gwdg.de>
To:        Charles Howse <chowse@charter.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Tar question
Message-ID:  <20030903133619.B41403-100000@gwdu60.gwdg.de>
In-Reply-To: <003101c3720d$a43d54d0$04fea8c0@moe>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 3 Sep 2003, Charles Howse wrote:

> I'm a little confused about the arguments for tar.
> I want to tar the contents of a directory and save that .tgz file for
> backup purposes.
>
> Problem is, when I copy larry.tgz to /disk2 and:
> Tar xvfz larry.tgz
> It creates the /disk2 file structure within /disk2.
>
> # cd
> # ls /disk2
> # freebsd larry (directories)
> # tar cvfz larry.tgz /disk2
> # cp larry.tgz /disk2
> # cd /disk2
> # tar xvfz larry.tgz
> # ls
> # freebsd larry disk2 (directories)
>
> How can I make tar not create the directory structure within the same
> directory?
> Does that make sense?
> I tried tar cvfzP, no joy.
>
> Man tar didn't have anything that jumped out at me, but I could have
> missed or misunderstood something.
> If the solution is in the man page, I would appreciate a reference to
> the section, so I can re-read it to understand.

My suggestion is:

tar cvCfz /disk2 larry.tgz .

tar will cd to /disk2 before interpreting the dot - thus the content of
/disk2 will be archived, but without a leading "disk2" in the table of
contents.

Regards
Konrad Heuer (kheuer2@gwdg.de)  ____            ___  _______
GWDG                           / __/______ ___ / _ )/ __/ _ \
Am Fassberg                   / _// __/ -_) -_) _  |\ \/ // /
37077 Goettingen             /_/ /_/  \__/\__/____/___/____/
Germany





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030903133619.B41403-100000>