From owner-freebsd-questions@FreeBSD.ORG Sat Feb 11 01:33:13 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 131A11065670 for ; Sat, 11 Feb 2012 01:33:13 +0000 (UTC) (envelope-from mail@ozzmosis.com) Received: from outbound.icp-qv1-irony-out2.iinet.net.au (outbound.icp-qv1-irony-out2.iinet.net.au [203.59.1.107]) by mx1.freebsd.org (Postfix) with ESMTP id 8A0278FC1B for ; Sat, 11 Feb 2012 01:33:12 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsIAJm+NU/KoRDx/2dsb2JhbABErnB/gQeBcgEBBAE6TwsNORQYRId8uDqJJoJDBQQGCwIEBwIHBwsEAQsBDQEMBAiDXgN+gjpjBJUvhUg1jHw X-IronPort-AV: E=Sophos;i="4.73,399,1325433600"; d="scan'208";a="790931857" Received: from unknown (HELO smtp.phoenix) ([202.161.16.241]) by outbound.icp-qv1-irony-out2.iinet.net.au with ESMTP; 11 Feb 2012 09:05:16 +0800 Received: by smtp.phoenix (Postfix, from userid 1001) id 8A67C296A; Sat, 11 Feb 2012 12:05:14 +1100 (EST) Date: Sat, 11 Feb 2012 12:05:14 +1100 From: andrew clarke To: freebsd-questions@freebsd.org Message-ID: <20120211010514.GA54353@ozzmosis.com> References: <1237723287.20120207235924@yandex.ru> <4F31A260.20109@infracaninophile.co.uk> <20120207231716.31aa8bc3@gumby.homeunix.com> <20120209032544.GA58560@ozzmosis.com> <4F3541D6.5080505@infracaninophile.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4F3541D6.5080505@infracaninophile.co.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: 'rm' Can not delete files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Feb 2012 01:33:13 -0000 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