4

I accidentally redirected the output of a command to --help rather than passing it as a parameter. How do I escape the dashes to I can remove the file? This is on a headless server, so I'll need to do it from the command line.

1 Answers1

7

You can use this:

rm -- --help
heartsmagic
  • 5,350
  • 2
    Also, while many applications accept a -- or - flag/option to prevent all subsequent arguments from being interpreted as flags/options, in the event that you had to operate on a file called --help (or similar) with a command that did not have a -- or - flag/option with that meaning, you could use COMMAND ./--help (where COMMAND is replaced with the actual name of the command, of course, and --help is replaced with the actual name of the file that starts with -- or -). – Eliah Kagan Nov 10 '11 at 04:39
  • Hmm..I never knew that -- prevented prevented arguments from being interpreted any further. – Andrew Gunnerson Nov 10 '11 at 07:42
  • @Eliah: Nice point! I'll remember that the next time I make the same mistake :P – Andrew Gunnerson Nov 10 '11 at 07:43
  • One additional hint: When you're unsure if you're removing the correct file, add the -i parameter and you'll be asked for confirmation before a file is being deleted. – bseibold Nov 10 '11 at 17:20