Date: Sun, 7 May 2000 19:45:15 -0700 (PDT) From: "Eric J. Schwertfeger" <ejs@bfd.com> To: Doug Barton <DougB@gorean.org> Cc: Steve Price <sprice@hiwaay.net>, Darren Wyn Rees <merlin@netlink.co.uk>, freebsd-questions@FreeBSD.ORG Subject: Re: "rm -rf *" - "argument list too long" Message-ID: <Pine.BSF.4.10.10005071933480.88087-100000@harlie.bfd.com> In-Reply-To: <3916221B.865C810B@gorean.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.10005071933480.88087-100000>