Date: Mon, 28 Aug 2006 11:42:18 -0500 From: "Rick C. Petty" <rick-freebsd@kiwi-computer.com> To: freebsd-hackers@FreeBSD.ORG, mlobo@digiart.art.br Subject: Re: A handy utility (at least for me) Message-ID: <20060828164218.GA34151@megan.kiwi-computer.com> In-Reply-To: <200608281618.k7SGIwWh065261@lurza.secnetix.de> References: <20060826225350.GA20172@megan.kiwi-computer.com> <200608281618.k7SGIwWh065261@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 28, 2006 at 06:18:58PM +0200, Oliver Fromme wrote: > Rick C. Petty wrote: > > > > I find that the following command works just fine for me: > > > > find /usr/ports -type d -name work -prune -print -delete > > The following is probably the most efficient solution. > It doesn't run into all subdirectories (and works with > an arbitrary numebr of subdirectories). > > cd /usr/ports; echo */*/work | xargs rm -rf You might as well just do: rm -rf /usr/ports/*/*/work because using xargs doesn't gain you anything in this case. How does your example work with an arbitrary number of subdirectories? Your example does't work if the number of work directories exceeds the maximum number of arguments (4096 IIRC), which can happen amidst 16,000 ports. This bit me once so I use find now (granted this was before I was using portupgrade). Also I don't see how your example is any more efficient than find-- you're just making the shell do the work instead of find. In either case, it's just a sequence of opendir()/readdir(). In fact your example would start secondary processes to do the directory removal; find has this built in and thus doesn't have the overhead of process forking. Perhaps if on an arbitrary directory tree, find may not be as efficient, but the only directories deeper than depth of two (in my example) are work directories, and they would be pruned. -- Rick C. Petty
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060828164218.GA34151>