Skip site navigation (1)Skip section navigation (2)
Date:        Fri, 17 Mar 2000 01:00:43 +0100
From:      Erik Trulsson <ertr1013@student.csd.uu.se>
To:        freebsd-questions@FreeBSD.ORG
Subject:   Re: tar question
Message-ID:  <20000317010043.A1003@student.csd.uu.se>
In-Reply-To: <20000317102353.A37209@jonc.logisticsoftware.co.nz>; from jonc@logisticsoftware.co.nz on Fri, Mar 17, 2000 at 10:23:54AM %2B1300
References:  <852568A4.006C7023.00@danube.ccity.com> <20000317102353.A37209@jonc.logisticsoftware.co.nz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Mar 17, 2000 at 10:23:54AM +1300, Jonathan Chen wrote:
> On Thu, Mar 16, 2000 at 02:52:43PM -0500, David_Gadoury@ccnotes.ccity.com wrote:
> 
> > 
> > 
> > what exactly does the following command do. (how does it work)
> > 
> > tar cf - . | (cd /usr/var; tar xf - )
> 
> It's copying the current directory downwards onto /usr/var.
> 
> "tar cf - ." will instruct tar to output the archive onto std output.
> 
> "(cd /usr/var; tar xf -)" will run in a sub-shell, which will first
> change to /usr/var and then extract an archive from stdin. The "(..)"
> is essential so that the extraction-process ends up in the right place
> without affecting the archiving-process.
> 


Another way of doing the same thing is:

tar cf - . | tar xf - -C /usr/var

The advantage is that you don't need to start an extra shell just to get
things into the right directory.
I would also suggest adding the "v" flag to one of the tar invocations 
so that one can see what happens. 
Thereby ending up with:

tar cf - . | tar xvf - -C /usr/var 




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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