我想在目录中添加一些目录。
不幸的是,这些目录位于包含空格的Windows路径中(例如“文档和设置”)

我尝试失败:

创建变量:

43598811@E250BZD20015026 ~
$ winhome="/cygdrive/c/Documents\ and\ Settings/43598811/"

43598811@E250BZD20015026 ~
$ cd $winhome
bash: cd: /cygdrive/c/Documents\: No such file or directory

43598811@E250BZD20015026 ~
$ cd "$winhome"
bash: cd: /cygdrive/c/Documents\ and\ Settings/43598811/: No such file or directory

创建别名:
43598811@E250BZD20015026 ~
$ alias winhome="/cygdrive/c/Documents\ and\ Settings/43598811/"

43598811@E250BZD20015026 ~
$ winhome
bash: /cygdrive/c/Documents and Settings/43598811/: is a directory

43598811@E250BZD20015026 ~
$ cd winhome
bash: cd: winhome: No such file or directory

使用软链接(soft link):
它正在工作...但是我不想使用它

有什么建议吗?

最佳答案

这有效:

$ winhome="/cygdrive/c/Documents and Settings/"
$ cd "$winhome"
$ pwd
/cygdrive/c/Documents and Settings

关于bash - Cygwin:使用包含Windows路径(其中带有空格)的路径变量,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4334467/

10-11 06:44