From owner-freebsd-hackers@FreeBSD.ORG Mon Aug 28 16:42:20 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6DC9716A4DE for ; Mon, 28 Aug 2006 16:42:20 +0000 (UTC) (envelope-from rick@kiwi-computer.com) Received: from kiwi-computer.com (megan.kiwi-computer.com [63.224.10.3]) by mx1.FreeBSD.org (Postfix) with SMTP id 28CCA43D55 for ; Mon, 28 Aug 2006 16:42:19 +0000 (GMT) (envelope-from rick@kiwi-computer.com) Received: (qmail 34303 invoked by uid 2001); 28 Aug 2006 16:42:18 -0000 Date: Mon, 28 Aug 2006 11:42:18 -0500 From: "Rick C. Petty" To: freebsd-hackers@FreeBSD.ORG, mlobo@digiart.art.br Message-ID: <20060828164218.GA34151@megan.kiwi-computer.com> References: <20060826225350.GA20172@megan.kiwi-computer.com> <200608281618.k7SGIwWh065261@lurza.secnetix.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200608281618.k7SGIwWh065261@lurza.secnetix.de> User-Agent: Mutt/1.4.2.1i Cc: Subject: Re: A handy utility (at least for me) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rick-freebsd@kiwi-computer.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Aug 2006 16:42:20 -0000 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