From owner-freebsd-questions@FreeBSD.ORG Mon Nov 10 16:31:15 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1DADF106564A for ; Mon, 10 Nov 2008 16:31:15 +0000 (UTC) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: from gizmo.acns.msu.edu (gizmo.acns.msu.edu [35.8.1.43]) by mx1.freebsd.org (Postfix) with ESMTP id D77658FC18 for ; Mon, 10 Nov 2008 16:31:14 +0000 (UTC) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: from gizmo.acns.msu.edu (localhost [127.0.0.1]) by gizmo.acns.msu.edu (8.13.6/8.13.6) with ESMTP id mAAGRTph082135; Mon, 10 Nov 2008 11:27:29 -0500 (EST) (envelope-from jerrymc@gizmo.acns.msu.edu) Received: (from jerrymc@localhost) by gizmo.acns.msu.edu (8.13.6/8.13.6/Submit) id mAAGRTvV082134; Mon, 10 Nov 2008 11:27:29 -0500 (EST) (envelope-from jerrymc) Date: Mon, 10 Nov 2008 11:27:29 -0500 From: Jerry McAllister To: chloe K Message-ID: <20081110162729.GB81960@gizmo.acns.msu.edu> References: <257066.24717.qm@web57412.mail.re1.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <257066.24717.qm@web57412.mail.re1.yahoo.com> User-Agent: Mutt/1.4.2.2i Cc: freebsd-questions@freebsd.org Subject: Re: hundred files to tar and untar X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Nov 2008 16:31:15 -0000 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? > Just use cd. You can use cd in a script just like you would at the command line. cd /what/ever/the/source/directory/is tar cvf ../htmlstuff.tar /cc.html mkdir -p /where/ever/you/want/it cd /where/ever/you/want/it tar xvf /what/ever/the/source/directory/htmlstuff.tar This would eliminate the directory tree being recreated where you unroll the tar presuming that fantasy path I first cd to is, in your example, /var/web/data/verion If you want to preserve that directory path in the new place you do cd / tar cvf /htmlstuff.tar /what/ever/the/source/directory/is/cc.html mkdir -p /where/ever/you/want/it cd /where/ever/you/want/it tar xvf /htmlstuff.tar You can put that in a loop in your script if it can pick up the file names and directory paths to plug in the commands. > eg: > > tar cvf html.tar /var/web/data/verion/cc.html > > untar html.tar /var/web/data/root/cc.html > > Thank you > > > > > --------------------------------- > > > Yahoo! Canada Toolbar : Search from anywhere on the web and bookmark your favourite sites. Download it now! > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >