From owner-freebsd-questions@FreeBSD.ORG Fri Feb 10 16:12:17 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 D36C310656B5 for ; Fri, 10 Feb 2012 16:12:17 +0000 (UTC) (envelope-from m.seaman@infracaninophile.co.uk) Received: from smtp.infracaninophile.co.uk (smtp6.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3cd3:cd67:fafa:3d78]) by mx1.freebsd.org (Postfix) with ESMTP id 586BC8FC17 for ; Fri, 10 Feb 2012 16:12:17 +0000 (UTC) Received: from seedling.black-earth.co.uk (seedling.black-earth.co.uk [IPv6:2001:8b0:151:1:fa1e:dfff:feda:c0bb]) (authenticated bits=0) by smtp.infracaninophile.co.uk (8.14.5/8.14.5) with ESMTP id q1AGCD2B065412 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO) for ; Fri, 10 Feb 2012 16:12:13 GMT (envelope-from m.seaman@infracaninophile.co.uk) X-DKIM: OpenDKIM Filter v2.4.3 smtp.infracaninophile.co.uk q1AGCD2B065412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infracaninophile.co.uk; s=201001-infracaninophile; t=1328890333; bh=bDvCrNjFdYmthTFSE64EDWeaHV7Jiw2Fi9ITpIFFnVM=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Cc; b=SsCwURtrL1KhNufU8EfNNVMkz9HvCR0Lk1AioAmxvuQbq0LOb3yMcXo05yxNOFSe1 FTu85F69mRTDGlsU0drVPKCFC+DH4fdkZDw3YOy1Rxg+OAR1ZU8y5uvqiGJFmGF3hV UKdRW40Xp2k/MSuQlMUtbGk+BBWSkpDkGapbMZm4= Message-ID: <4F3541D6.5080505@infracaninophile.co.uk> Date: Fri, 10 Feb 2012 16:12:06 +0000 From: Matthew Seaman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0) Gecko/20120129 Thunderbird/10.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <1237723287.20120207235924@yandex.ru> <4F31A260.20109@infracaninophile.co.uk> <20120207231716.31aa8bc3@gumby.homeunix.com> <20120209032544.GA58560@ozzmosis.com> In-Reply-To: X-Enigmail-Version: 1.3.5 OpenPGP: id=60AE908C Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig853E0A02FE49DEB34FD48CB7" X-Virus-Scanned: clamav-milter 0.97.3 at lucid-nonsense.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on lucid-nonsense.infracaninophile.co.uk 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: Fri, 10 Feb 2012 16:12:18 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig853E0A02FE49DEB34FD48CB7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable >>> ls -1 | xargs rm >> but be aware that that wont work for filenames with spaces. True. Can't do that using ls to generate the list of filenames as there is no option to generate a null-separated list amongst ls's multitudinous collection. > 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. >> 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.= Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate JID: matthew@infracaninophile.co.uk Kent, CT11 9PW --------------enig853E0A02FE49DEB34FD48CB7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.16 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk81Qd0ACgkQ8Mjk52CukIyeeACdHapWiQOvKljWAEg1LuN9Jdux oqEAnAkziwcLF6fEb6RjpQgiKlyUyDRI =Mz77 -----END PGP SIGNATURE----- --------------enig853E0A02FE49DEB34FD48CB7--