Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <199908231908.NAA03986@chorus> Date: Mon, 23 Aug 1999 13:08:16 -0600 (MDT) From: "13mb80000-HallM(DR3132)37x10" Reply-To: "13mb80000-HallM(DR3132)37x10" Subject: Re: B20.1: Problem with recursive rm (rm -r) on Windows98 To: cygwin AT sourceware DOT cygnus DOT com X-Mailer: dtmail 1.2.1 CDE Version 1.2.1 SunOS 5.6 sun4m sparc Content-Type: text X-Sun-Text-Type: ascii > > 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 also, that executes the rm command fewer times, so there is less process creation/deletion overhead involved. If you needed to do something more complex than just a single command, and you need the power of the shell to manipulate whatever files you are finding, another construct that is handy is: find . -name *.d | while read i;do rm -f $i;done BUT.. be sure that whatever commands you execute do not read from standard in (i.e. be careful about executing "rsh ..." since it reads its standard input and starts shipping to the remote machine, it will suck up the rest of the input file names). Such commands should be given a flag to stop reading standard input (e.g. "rsh -n ...") or have their input re-directed from /dev/null. Still, if it is something that can be done by stringing arguments with xargs, that's by far the safest and most efficient way to do it. marcus -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com