Date: Sun, 7 May 2000 16:41:39 -0400 From: "Crist J. Clark" <cjc@cc942873-a.ewndsr1.nj.home.com> To: Darren Wyn Rees <merlin@netlink.co.uk> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: "rm -rf *" - "argument list too long" Message-ID: <20000507164139.A23187@cc942873-a.ewndsr1.nj.home.com> In-Reply-To: <20000507201410.M540@netlink.co.uk>; from merlin@netlink.co.uk on Sun, May 07, 2000 at 08:14:10PM %2B0000 References: <20000507201410.M540@netlink.co.uk>
index | next in thread | previous in thread | raw e-mail
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 <directory name>", 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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000507164139.A23187>
