Question

Trying to mkdir with a leading hyphen in the name.

 mkdir -foo-
 mkdir '-foo-'
 mkdir `-foo-`
 mkdir `echo '-foo-'`

None of these work. Is there any way to do this?

Était-ce utile?

La solution

Try using -- to disable further option parsing:

mkdir -- -foo

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top