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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top