From owner-freebsd-questions Sun May 7 13:41:48 2000 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id 6776B37BB9A for ; Sun, 7 May 2000 13:41:45 -0700 (PDT) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.9.3) id QAA23352; Sun, 7 May 2000 16:41:39 -0400 (EDT) (envelope-from cjc) Date: Sun, 7 May 2000 16:41:39 -0400 From: "Crist J. Clark" To: Darren Wyn Rees Cc: freebsd-questions@FreeBSD.ORG Subject: Re: "rm -rf *" - "argument list too long" Message-ID: <20000507164139.A23187@cc942873-a.ewndsr1.nj.home.com> Reply-To: cjclark@home.com References: <20000507201410.M540@netlink.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20000507201410.M540@netlink.co.uk>; from merlin@netlink.co.uk on Sun, May 07, 2000 at 08:14:10PM +0000 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, May 07, 2000 at 08:14:10PM +0000, Darren Wyn Rees wrote: > I'm in a directory with a tonne of files I wish to delete. > I type "rm -rf *", but it won't work, it gives "/bin/rm: Argument > list too long". So how can I delete these many files ? > > I can "cd ..", and then "rm -rf ", and that works. > > However, what if I didn't wish to remove directories. In that > case, what would I do to remove the files ? Someone already pointed to xargs(1). > PS. (I'm finding it takes some getting used to putting > the operands to many commands immediately after the command. > Why is this so with FreeBSD? With Linux I can type 'rm * -rf' etc.) % man rm . . . NOTE The rm command uses getopt(3) to parse its arguments, which allows it to accept the `--' option which will cause it to stop processing flag op- tions at that point. This will allow the removal of file names that be- gin with a dash (`-'). For example: rm -- -filename The same behavior can be obtained by using an absolute or relative path reference. For example: rm /home/user/-filename rm ./-filename See the getopt(3) manpage to see more detail why, % rm * -rf Would not work. With the syntax you describe the above command chokes if there is a file named, say, '-filename' in the pwd. -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message