[Discuss] Command line question

Scott Petersen scott at slal.net
Wed Jul 26 15:22:51 PDT 2006


On Wed, Jul 26, 2006 at 03:06:15PM -0700, Adam Parkin wrote:
> Quick one for the gurus: I have a directory structure that looks 
> something like:
> 
> ~/temp
> 	-> user1
> 		-> CVS
> 		-> a3
> 			-> CVS
> 	-> user2
> 		-> CVS
> 		-> a3
> 			-> CVS
> 
> etc, etc for about 37 different "userX" directories.  What I want to do 
> is remove all of the CVS directories from this tree so that I end up with:
> 
> ~/temp
> 	-> user1
> 		-> a3
> 	-> user2
> 		-> a3
> 
> What's a quick way of doing this on the command line?

A slight variation on another response:

find ~/temp -type d -name CVS -print0 |xargs --null rm -rf

Finds all directories named CVS under ~/temp and prints them to stdout
with an ASCII 0 (null) seperator. Xargs reads stdin and seperates the
arguments on the ASCII 00 and deletes it using the recursive and force
arguments.

(Gee, this is almost like the Alpha Geek competition at Linuxfest.)

Cheers
Scott


More information about the Discuss mailing list