Subject: Re: "rm *" files "-f" and "-r" - weird behaviour...
To: Ian Zagorskih <>
From: Martin Husemann <>
List: tech-userlevel
Date: 01/20/2006 13:20:27
On Fri, Jan 20, 2006 at 06:12:36PM +0600, Ian Zagorskih wrote:
> $ echo > -r
> $ echo > -f 
> $ rm *
> IMHO quite weird rm behavior, no? :)

What do you not understand about it? Your shell expands * into all files,
and you get "rm -r -f foo" as a result. Now rm executes this and the result
is as expected.

If you don't want to risk this, do not use * in this context or use -- to stop
option parsing:

 $ rm -- *
 rm: foo: is a directory

(but it will rm the -r and -f file)

Another common way to express this is to use

 rm ./*

which has the same effect, basically (since no options start with ./)