Pregunta

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?

¿Fue útil?

Solución

Try using -- to disable further option parsing:

mkdir -- -foo

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top