Search code examples
command-linemv

Move file with a dash


I move file using Midnight Commander to file with name "-name.csv". But 'mc' thinks I use option. Why is this happening? And how I can move to file with name like "-name.csv".

desktop:~/s$ mv name.csv "-name.csv"
mv: invalid option -- 'a'

Solution

  • It's not mc, it's mv. Quoting doesn't help because the quotes are interpreted by the shell so mv receives unquoted parameters name.csv and -name.csv. You need to hide the dash so that option parser in mv stops thinking it's an option. Use relative path ./ for the current directory, or full path:

    mv name.csv ./-name.csv
    mv name.csv "`pwd`"/-name.csv