rm a file with name '--min-size=8'

Peter Gordon peter at thecodergeek.com
Wed Oct 18 21:20:00 UTC 2006


Yuandan Zhang wrote:
> Hi,
> I incidantly created file named as '--min-size=8'. In fact, I don't know how
> it was created. I have difficulty to remove it using "rm -rf \--min-size=8
> or other ways?

GNU rm, like most other GNU tools, will treat a single set of double hyphens
("--") as the end of the option listing, so everything after it will be taken
literally, so something like the following should work:

$ rm -i -- --min-size=8

(Note the "-i" option: Be sure that the file it is asking to delete is the file
that you want to remove. rm can be a both a very useful tool and an extremely
dangerous weapon against one's system. Think of it as analogous, in some ways,
to a knife: Extremely useful when used properly, but it can be quite deadly if
great care is not taken in its use.)

Alternatively, you can escape every hyphen and equals sign within the file name:
$ rm -i \-\-min\-size\=8

I'm a big fan of using the double-hyphen method though, as it's clearer to me.

Hope that helps.
-- 
Peter Gordon (codergeek42)
This message was sent through a webmail
    interface, and thus not signed.




More information about the users mailing list