Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Jan 2006 12:35:46 +0000
From:      RW <list-freebsd-2004@morbius.sent.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: rm - Argument list too long
Message-ID:  <200601291235.47999.list-freebsd-2004@morbius.sent.com>
In-Reply-To: <20060129032722.GB85318@alexis.mi.celestial.com>
References:  <927ad6550601271534r17a6ddb2jd90b930f744d170f@mail.gmail.com> <200601281733.47099.kirk@strauser.com> <20060129032722.GB85318@alexis.mi.celestial.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday 29 January 2006 03:27, Bill Campbell wrote:
> On Sat, Jan 28, 2006, Kirk Strauser wrote:
> >On Friday 27 January 2006 17:52, Paul Schmehl wrote:
> >> for files in *.*
> >> do
> >> rm $files
> >> done
> >
> >Don't ever, *EVER* blindly unlink glob expansions.  It's bad for you.
> >
> >Instead, use something like:
> >
> >    find . -name 'sess.*' -delete
>
> While that's good advice, it doesn't answer the question of argument list
> too long.

Yes, it does. 

The glob is expanded by find, the "argument list too long" problem occurs when 
the glob is expanded by the shell.

> The short answer is read ``man xargs''.
>
> find . | xargs command

That should be:

find . -print0  | xargs  -0 command

In FreeBSD null termination is needed to handle names with spaces, and not 
just the rare problem of names containing newlines. It's easier to just use 
find with the ls, delete and exec[dir] options.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200601291235.47999.list-freebsd-2004>