Make directory with leading hyphen Make directory with leading hyphen unix unix

Make directory with leading hyphen


Try using -- to disable further option parsing:

mkdir -- -foo


How about

$ mkdir ./-dir

in order to specify the directory with the current dir prefixed. The same 'trick' can be used with all other command line utils (e.g. rmdir, rm etc.).

I perhaps wouldn't create such a directory, though, unless it's really necessary. It's a little counter-intuitive and may cause similar confusion for others in the future.