Find the answer to your Linux question:
Results 1 to 3 of 3
I am trying to move a file that starts with "-" with mv. Whenever I try to move it I get an error saying I have an invalid option because ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Oct 2006
    Posts
    101

    renaming a file starting with -


    I am trying to move a file that starts with "-" with mv. Whenever I try to move it I get an error saying I have an invalid option because the file starts with -. I have tried to put a \ before it with no luck and I have tried quotes. Thanks in advance!
    --Erik

  2. #2
    Linux Guru
    Join Date
    Nov 2004
    Posts
    6,110
    There is an old GNU trick that if you want to specify the end of switches you can pass a double hypen '--' with no action after it -
    Code:
    mv -- -somefile somefile
    Escaping doesn't usually work, nor do quotes. Just use the double hyphen.

  3. #3
    Linux Newbie
    Join Date
    Oct 2006
    Posts
    101
    worked great, thanks!
    --Erik

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •