Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You can use this:

rm -- --help
share|improve this answer
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 4:39
    
Hmm..I never knew that -- prevented prevented arguments from being interpreted any further. –  Xiao-Long Chen Nov 10 '11 at 7:42
    
@Eliah: Nice point! I'll remember that the next time I make the same mistake :P –  Xiao-Long Chen Nov 10 '11 at 7: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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.