From owner-freebsd-questions@FreeBSD.ORG Thu Feb 9 03:53:31 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 7DEE9106564A for ; Thu, 9 Feb 2012 03:53:31 +0000 (UTC) (envelope-from mail@ozzmosis.com) Received: from outbound.icp-qv1-irony-out3.iinet.net.au (outbound.icp-qv1-irony-out3.iinet.net.au [203.59.1.148]) by mx1.freebsd.org (Postfix) with ESMTP id 0555B8FC14 for ; Thu, 9 Feb 2012 03:53:30 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av0EACs8M0/KoRDx/2dsb2JhbABDrx+BB4FyAQEEATpECwsNCy4UGESHfLJpiByDNxkFGgIEBwIHBwsEAQsBDQEMBAUDg14DfoI6YwSVLIVGNYx3 X-IronPort-AV: E=Sophos;i="4.73,387,1325433600"; d="scan'208";a="760443544" Received: from unknown (HELO smtp.phoenix) ([202.161.16.241]) by outbound.icp-qv1-irony-out3.iinet.net.au with ESMTP; 09 Feb 2012 11:25:45 +0800 Received: by smtp.phoenix (Postfix, from userid 1001) id 640971A6D; Thu, 9 Feb 2012 14:25:44 +1100 (EST) Date: Thu, 9 Feb 2012 14:25:44 +1100 From: andrew clarke To: freebsd-questions@freebsd.org Message-ID: <20120209032544.GA58560@ozzmosis.com> References: <1237723287.20120207235924@yandex.ru> <4F31A260.20109@infracaninophile.co.uk> <20120207231716.31aa8bc3@gumby.homeunix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120207231716.31aa8bc3@gumby.homeunix.com> 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: Thu, 09 Feb 2012 03:53:31 -0000 On Tue 2012-02-07 23:17:16 UTC+0000, RW (rwmaillists@googlemail.com) wrote: > On Tue, 07 Feb 2012 22:14:56 +0000 > Matthew Seaman wrote: > > > ls -1 | xargs rm > > but be aware that that wont work for filenames with spaces. 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. The above will also try to 'rm' directories, which won't work. Instead I would use 'find': find . -type f -depth 1 -delete This will also work with filenames with spaces. 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.) Regards Andrew