Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Nov 2008 09:19:30 -0600
From:      David Kelly <dkelly@hiwaay.net>
To:        chloe K <chloekcy2000@yahoo.ca>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: hundred files to tar and untar
Message-ID:  <20081110151930.GB73102@Grumpy.DynDNS.org>
In-Reply-To: <257066.24717.qm@web57412.mail.re1.yahoo.com>
References:  <257066.24717.qm@web57412.mail.re1.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Nov 10, 2008 at 08:10:36AM -0500, chloe K wrote:
> Hi 
>    
>   I have hundred files to tar
>    
>   How can I make tar the file but untar in different folder?
>    
>   eg:
>    
>   tar cvf html.tar /var/web/data/verion/cc.html
>    
>   untar html.tar /var/web/data/root/cc.html
>    
>   Thank you

RTFM. Specifically look at the -C option.

Or you could do it the simple way (note parenthesis, the cd only applies
within the parenthesis, when the command clompletes your shell is back
to the original directory):

(cd /var/web/data/verion/cc.html ; tar -cvf <somewhere>/html.tar * )
(cd /var/web/data/root/cc.html   ; tar -xvf <somewhere>/html.tar   )

The above does not store the path prefix in the tar archive, which is
perhaps the problem you were trying to solve?

-- 
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.



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