5

Possible Duplicate:
How do I delete a file whose name begins with "--"?

Due to mismatched switches when I was trying to run a command, I have a log file named -w in a directory. I want to see its contents with cat (or less) and then delete it.

I've tried escaping it with backslashes, single-quotes, double-quotes, parentheses, and backticks, but cat always complains that w is an unknown option.

How can I properly reference this file?

user394
  • 14,404
  • 21
  • 67
  • 93

2 Answers2

6

Almost all commands allow -- as separator between options parameters and positional parameters. You can use the following:

cat -- -w
rm -f -- -w
4

Prefix it with the path. For instance:

cat /home/whatever/-w
rm /home/whatever/-w
nico
  • 568