9

How can I handle (e.g. apply mv command) in a command shell the files with leading dash (-) in names? The command

mv -weirdfilename.zip normalfilename.zip 

naturally accepts - at the beginning of a filename as an argument.

0

1 Answer 1

16

Two ways:

  • -- indicates end of command options, so everything follows that are treated as arguments:

    mv -- -weirdfilename.zip normalfilename.zip 
    
  • Use ./ to indicate a file name explicitly:

    mv ./-weirdfilename.zip normalfilename.zip 
    
1
  • 2
    It's worth noting that -- might not always work for just - as a file name since it might have special meaning (e.g. stdin/stdout) in some programs. Commented Aug 17, 2016 at 12:54

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.