Tiny Deathstars of Foulness

Recently I needed to create a bunch of files that had names starting with a dash. If you simply run touch followed by the filename, if the filename starts with a dash, it will throw an error that there’s an illegal option. Therefore, you must escape out the dash by passing a double dash in front of it. For example, to create a file with a dash in the name, use the following syntax:

touch -- -man

Likewise, to remove that file:

rm -- -man

You can also use the double dash when passing commands to ssh rather than have ssh interpret them as arguments, making it useful for command and control scripting. For example, to ssh into a host and repair a volume:

ssh -- cvfsck goldengirls --nv

The double dash indicates there are no more command line options for the command in front of it.

January 7th, 2014

Posted In: Mac OS X, Mac OS X Server, Mac Security, Ubuntu, Unix

Tags: , , , , ,