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.

This question already has an answer here:

While using grep with -oG flag I accidentally create a file named -v.

-rw-rw-r-- 1 username username 334 Feb 10 14:29 -v

Now I cannot figure out how to get rid of it.

I've tried:

rm -v
rm "-v"
rm '-v'
rm -f "-v"
rm \-v

This is on a server so I only have the command line. How do I remove this file?

share|improve this question

marked as duplicate by BuZZ-dEE, Lucio, Seth, karel, Eric Carvalho Feb 12 at 0:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 11 down vote accepted

The "--" argument to mv surely works (it means: "stop to interpreting strings starting with - as options from now on"), but it is worth to know also

rm ./-v 

which will work also with commands that do not have the "--" flag.

EDIT: well-behaved commands should respect the -- flag. But you never know.

share|improve this answer
2  
All GNU programs should adhere to --. It may be defined in POSIX as well. Yup, its here. –  minerz029 Feb 10 at 21:12
    
Exactly. ./ will ALWAYS work. -- will PROBABLY work. –  Alan Shutko Feb 11 at 3:50
    
Didn't even think of ./ and the -- flag is good to know. –  dan08 Feb 11 at 14:15
rm -- -v

-- signifies end of options.

share|improve this answer

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