9

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?

phs
  • 319
Dan
  • 6,784

2 Answers2

14

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.

Rmano
  • 32,167
13
rm -- -v

-- signifies end of options.

kiri
  • 28,986