Date: Thu, 12 May 2005 14:31:40 -0300 From: Alejandro Pulver <alejandro@varnet.biz> To: racerx@makeworld.com Cc: FreeBSD - Questions <freebsd-questions@freebsd.org> Subject: Re: Scripting help Message-ID: <20050512143140.1c1301b5@ale.varnet.bsd> In-Reply-To: <42838801.1000507@makeworld.com> References: <42838801.1000507@makeworld.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 12 May 2005 11:44:49 -0500
Chris <racerx@makeworld.com> 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 <file>
/destination/dir" replacing "<file>" 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050512143140.1c1301b5>
