From owner-freebsd-questions Thu Mar 16 16: 1: 5 2000 Delivered-To: freebsd-questions@freebsd.org Received: from merganser.its.uu.se (merganser.its.uu.se [130.238.6.236]) by hub.freebsd.org (Postfix) with ESMTP id 2602E37C135 for ; Thu, 16 Mar 2000 16:01:02 -0800 (PST) (envelope-from ertr1013@student.csd.uu.se) Received: from regulus.its.uu.se ([130.238.7.19]:62779 "HELO ertr1013.student.csd.uu.se") by merganser.its.uu.se with SMTP id ; Fri, 17 Mar 2000 01:00:48 +0100 Received: (qmail 1041 invoked by uid 1001); 17 Mar 2000 00:00:43 -0000 Date: Fri, 17 Mar 2000 01:00:43 +0100 From: Erik Trulsson To: freebsd-questions@FreeBSD.ORG Subject: Re: tar question Message-ID: <20000317010043.A1003@student.csd.uu.se> References: <852568A4.006C7023.00@danube.ccity.com> <20000317102353.A37209@jonc.logisticsoftware.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20000317102353.A37209@jonc.logisticsoftware.co.nz>; from jonc@logisticsoftware.co.nz on Fri, Mar 17, 2000 at 10:23:54AM +1300 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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