Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Feb 2012 12:05:14 +1100
From:      andrew clarke <mail@ozzmosis.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: 'rm' Can not delete files
Message-ID:  <20120211010514.GA54353@ozzmosis.com>
In-Reply-To: <4F3541D6.5080505@infracaninophile.co.uk>
References:  <1237723287.20120207235924@yandex.ru> <4F31A260.20109@infracaninophile.co.uk> <20120207231716.31aa8bc3@gumby.homeunix.com> <20120209032544.GA58560@ozzmosis.com> <CAE7N2kdmbm_5=c8oNknYQE5HOrvVjtfS4XTGYvxTjEQVbGr-7Q@mail.gmail.com> <4F3541D6.5080505@infracaninophile.co.uk>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Fri 2012-02-10 16:12:06 UTC+0000, Matthew Seaman (m.seaman@infracaninophile.co.uk) wrote:

> > In addition, I don't believe it solves the OP's initial problem of the
> > argument list being too long!  You'd probably need to use the xargs -n
> > switch here.
> 
> Go and read the xargs(1) man page carefully.  xargs is specifically
> designed to avoid arglist overflows.

Ah, I grepped for 'limit' and 'overflow', didn't see anything
applicable, and didn't notice the -s switch.  That it avoids arglist
overflows should perhaps be written more obviously in the man page
(though I'm not sure how...)

> >> Or the scenic route, using xargs, with one rm per file (slower):
> >>
> >> find . -type f -depth 1 -print0 | xargs -n1 -0 rm -f
> >>
> >> (The "scenic route" is useful if you want to do something else with
> >> the files instead of deleting them with rm.)
> 
> In this case, if you're going to call rm repeatedly with only one arg,
> then xargs is pretty pointless.  You might as well do:
> 
>    find . -type f -depth 1 -exec rm -f '{}' ';'
> 
> but let's not leave people in any doubt that this is not the best option.

True, but I can never remember the syntax for -exec.  :-)

Regards
Andrew



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20120211010514.GA54353>