From owner-freebsd-questions@FreeBSD.ORG Thu May 12 17:30:27 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5AFF516A4CE for ; Thu, 12 May 2005 17:30:27 +0000 (GMT) Received: from relay.pair.com (relay00.pair.com [209.68.1.20]) by mx1.FreeBSD.org (Postfix) with SMTP id 9EA8643D41 for ; Thu, 12 May 2005 17:30:26 +0000 (GMT) (envelope-from alejandro@varnet.biz) Received: (qmail 15075 invoked from network); 12 May 2005 17:30:25 -0000 Received: from unknown (HELO ale.varnet.bsd) (unknown) by unknown with SMTP; 12 May 2005 17:30:25 -0000 X-pair-Authenticated: 200.115.214.28 Date: Thu, 12 May 2005 14:31:40 -0300 From: Alejandro Pulver To: racerx@makeworld.com Message-ID: <20050512143140.1c1301b5@ale.varnet.bsd> In-Reply-To: <42838801.1000507@makeworld.com> References: <42838801.1000507@makeworld.com> X-Mailer: Sylpheed-Claws 0.9.12b (GTK+ 1.2.10; i386-portbld-freebsd5.3) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: FreeBSD - Questions Subject: Re: Scripting help X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 May 2005 17:30:27 -0000 On Thu, 12 May 2005 11:44:49 -0500 Chris wrote: > I would like some advice on how to script something that will search > directories below a named root for all files ending with a certain > file extension. > > Then, mv or cp them to another location. > > > -- > Best regards, > Chris Hello, Try this: find /your/path -type f -name "*.tar" -exec cp {} /destination/dir \; /your/path - put here the root path to operate on -type f - type f means to search for "files" -name "*.tar" - search for anything (*) ending in ".tar" (shell pattern) -exec cp {} /destination/dir \; - execute the command "cp /destination/dir" replacing "" with each file found (one at time). The '\' is to escape the ';' (so it is not interpreted by the shell as a command separator). It is also posible to do much more complex functions with 'find'. For more information see "man find". Hope that helps. Best Regards, Ale