8

I am running Ubuntu, and would like to open a file whose file name starts with "-"(minus). When I try to open the file with pico or vim, the command thinks that the "-" sign is an option for the command.

I tried enclosing the file name with quotes ('), but I still get the same error.

I tried with bash and zsh, but still the same error.

PJ.
  • 3,017
  • 5
  • 21
  • 15

3 Answers3

26

In cases where command -- -file does not work - since not every program uses the same option parsing routines, command ./-file works everywhere.

Justin
  • 3,856
  • 18
  • 21
6

Place -- just before file name. In Unix it indicates the end of options for command.

To be more concrete, use: vim -- -file.

ilya
  • 213
  • 3
  • 6
  • 1
    Often, but not always, since it's left to the called command to interpret options however it prefers. For example, compare `echo -n test` and `echo -- -n test`. Check your manpages to be sure. – goldPseudo Mar 21 '10 at 05:23
0

I wanted to open a file start with - I'v tried many ways so that I started to search for it. finally I've tried to type cat ./- and it worked with me. thanks for your help Jastin