Removing files with strange names

1

Possible Duplicate:
Unix: Files starting with a dash, -

Somehow I ended up with a file named "-r". How do I remove it? rm -r doesn't work. I tried 'rm -i `ls -a`' to step through the file names, but it didn't prompt me to delete this one.

Edit A very hacky approach was to use python's os.unlink function. That worked, but I'm curious to hear other ways.

pythonic metaphor

Posted 2010-06-15T15:13:59.447

Reputation: 2 046

Question was closed 2010-06-22T19:12:45.580

Answers

6

From man rm:

To remove a file whose name starts with a '-', for example '-foo', use one of these commands:

rm -- -foo
rm ./-foo

Andy

Posted 2010-06-15T15:13:59.447

Reputation: 2 959