From owner-freebsd-questions Sun May 7 19:45:23 2000 Delivered-To: freebsd-questions@freebsd.org Received: from horst.bfd.com (horst.bfd.com [12.9.219.10]) by hub.freebsd.org (Postfix) with ESMTP id C0A7A37BBF8 for ; Sun, 7 May 2000 19:45:21 -0700 (PDT) (envelope-from ejs@bfd.com) Received: from HARLIE.bfd.com (bastion.bfd.com [12.9.219.14]) by horst.bfd.com (8.10.0/8.10.0) with ESMTP id e482jFt47356; Sun, 7 May 2000 19:45:16 -0700 (PDT) Date: Sun, 7 May 2000 19:45:15 -0700 (PDT) From: "Eric J. Schwertfeger" To: Doug Barton Cc: Steve Price , Darren Wyn Rees , freebsd-questions@FreeBSD.ORG Subject: Re: "rm -rf *" - "argument list too long" In-Reply-To: <3916221B.865C810B@gorean.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, 7 May 2000, Doug Barton wrote: > Steve Price wrote: > > > > Something like this doesn't work? > > > > ls * | xargs rm > > > > Seems simple enough and should do it all in one pass. :) > > Most of the proposed solutions would work, but the ones like this > suffer from having to spawn a new process for each file. Depending on > how many files are in the directory, this could take a very long time > (where "long time" is relative of course). A little shell manipulation > goes a long way here. Actually, this one won't create one process per file. xargs by default packs multiple arguments to each call of the executed program, . FreeBSD's xargs defaults to 5000 args or 63488 characters, whichever comes first, which is to say it's coming reasonably close to the best case, so you're not going to beat it by much unless you avoid shell globbing all together. My normal solution to this (yes, I hit it a lot at work) is either xargs or move the directory to a different name, create a new directory with the original name, mv the directories in the old directory into the new one, then rm -rf the old directory. Depends on the mood and the OS, we've got an old crufty SysV unix at work with a flakey xargs command. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message