removing file named -rf

How would I remove a file on linux/UNIX with the name "-rf"? Thank you.
[85 byte] By [erruttu] at [2007-11-25 23:23:27]
# 1
Try rm "-rf"
MAALATFT at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...
# 2

rm "-rf" probably won't work.

Try:

rm - -rf

Read the man page on rm. The first dash tells rm that all command switches are over and to expect the remains command arguments to be file names. The following is a cut from the rm man page:

NOTES

A - permits the user to mark explicitly the end of any com-

mand line options, allowing rm to recognize file arguments

that begin with a -. As an aid to BSD migration, rm will

accept -- as a synonym for -. This migration aid may disap-

pear in a future release. If a -- and a - both appear on the

same command line, the second will be interpreted as a file.

swoneill at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...
# 3
You could also try to do an rm \-rfThe \ removes the special significance of the symbol - and makes it a character.if that doesnt work let me know as there is the graphical way also by using the graphical file manager.-Piyush
fundoo72 at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...
# 4
Give this a try, I 'find' it works for me -find . -name '-rf' -exec rm {} \;I'd suggest you try it with just -print rather than the -exec first to assure yourself you are finding the file you want e.g. find . -name '-rf' -print
sbcdixie at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...
# 5
or you can use unlink(1M)which does not take argumentsunlink -rf
peterchun at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...
# 6
Use the "rm -i *" command. This'll prompt you for each file to remove. Select no to every file except the "-rf".
spamly at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...
# 7

None of the suggestions involving quoting the '-' will do any good -- the '-' is interpreted by the rm program, not by the shell.

The general solution to this problem is to use

rm ./-rf

or use a full path to the file. It is not necessary to invoke any other program to do the work. This works for rm and for any other program that might have this kind of problem, and you don't need to know any more about how to use the particular program such as whether it honors "--" as an end to the argument list.

Richard

RichardMMathews at 2007-7-5 18:10:41 > top of Java-index,General,Talk to the Sysop...