ubuntu-torso-in-a-white-topIt’s not often that you do run into this particular problem, but when you do it is a bit of an annoyance – most Ubuntu Server terminal commands (in other words linux commands), in our examples the cp (copy) and mv (move) instructions, can handle files beginning with a dash (-).

Why?

Well obviously because all commands accept parameter switches that are indicated with a dash (-) or double dash (–), meaning that when the command hits a file name staring with a dash, it basically assumes it to be a switch declaration which is obviously very wrong.

Luckily for us, even though it isn’t immediately all that apparent, there is a simple way to get around this and allow for the moving or copying of files starting with a dash – basically we delimit the file options by essentially instructing the application that we’ve finished including our switches.

We do this by placing a double dash (–) after the last lot of switches which tells the mv or cp command that what follows are filenames, thus allowing them to happily work on everything coming in next.

Useful to know.