Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Nov 2003 12:43:21 -0500
From:      Richard Coleman <richardcoleman@mindspring.com>
To:        Zhang Weiwu <weiwuzhang@hotmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: newbie: to pipe the result of a program as commandlineparameter for another.
Message-ID:  <3FBFA039.4010109@mindspring.com>
In-Reply-To: <3FBF5E71.8050809@hotmail.com>
References:  <3FBF5E71.8050809@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Zhang Weiwu wrote:

> Hello. I just checkouted a big program. What I want to do is to remove 
> all CVS/ folders from the hierarchy.
> 
> There might be other ways to do so (give me a hint?). What I can think 
> of is to run find(1) to find out all CVS folders, and pass them as 
> parameters of rm(1), but I don't know how to do so.

That's the purpose of the "xargs" command.  For instance, if you wanted 
to recursively delete all files in the directory /home/foo ending in 
".o", you could use the command

find /home/foo -name '*.o' -print | xargs rm -f

Of course, people will point out that find has options that will allow 
it to remove files directly.  But using xargs is a more general 
technique that will work in other situations.

For instance, if you wanted to "touch" all your *.c files so that they 
have current modification times, you could use the following

find /home/foo -name '*.c' -print | xargs touch

Also, xargs knows about the maximum size allowable for the command line, 
and will use the minimum number of process invocations necessary.

Richard Coleman
richardcoleman@mindspring.com




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