B20.1: Problem with recursive rm (rm -r) on Windows98

Fergus Henderson fjh@cs.mu.OZ.AU
Tue Aug 31 23:49:00 GMT 1999

On 20-Aug-1999, Earnie Boyd <earnie_boyd@yahoo.com> wrote:
> --- Stephane Bonenfant <sbonenfant@hotmail.com> wrote:
> > My problem is the following:
> > 
> > I have many level of directories with .d files and I want to remove them 
> > all. So I use the command "rm -rf *.d" which will only remove the file on 
> > the current directory. I though that it will do all other directories since 
> > I've use -r option. Is that because my directories are not name ending with 
> > .d ? Any suggestions
> I think the rm syntax requires that the directories recursed be in the argument
> list.  Therefore, unless the directory ends in .d it won't be seen.  To do what
> you want you need to create a foreach loop using find and rm.
> E.G.:
> foreach FILE in `find . -name *.d`; do rm -f $FILE; done

That command will fail if there are too many files ending in `.d',
due to fixed limits on the length of a command line.

A more robust (and more concise) alternative is to use

	find . -name *.d | xargs rm -f

Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: < http://www.cs.mu.oz.au/~fjh >  |  of excellence is a lethal habit"
PGP: finger fjh@        |     -- the last words of T. S. Garp.

Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

More information about the Cygwin mailing list