CD(1),并用空格变量(Cygwin的) [英] cd(1) and variables with spaces (cygwin)

查看:271
本文介绍了CD(1),并用空格变量(Cygwin的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直有一个相当不寻常的问题。在我的.bashrc文件,我有一个变量设置为路径名中有空格。我有一种感觉,这会造成问题,但我的设置方式类似的别名发挥各地,并得到它像这样的工作:

I've been having quite an unusual problem. In my .bashrc file, I have set a variable to a path name with spaces in it. I had a feeling this would cause problems, but I played around with setting an alias in a similar way and got it to work like so:

alias npp="\"/cygdrive/c/Program Files (x86)/Notepad++/notepad++.exe\""

现在,我想我可以用同样的伎俩对我的环境变量 -

Now, I thought I could use the same trick for my environment variable -

export PRO="\"/cygdrive/c/Program Files (x86)\""

这工作。有点。

[myName]  
$ echo $PRO  
"/cygdrive/c/Program Files (x86)"

[myName]  
$ cd $PRO  
bash: cd: "/cygdrive/c/Program: No such file or directory

我试着不除去双引号空间之前放置一种逃避,我已经试过单引号有和没有逃脱。我一直在使用重音符的报价尝试。我试过只是逃避,我试过

I've tried placing an escape before the space with and without removing the double quotes, I've tried single quotes with and without the escape. I've tried using grave accents as quotes. I've tried just the escape, I've tried

export PRO=/cygdrive/c/Program\\\ Files\\\ \\\(x86\\\)

这些都没有工作过。已经是唯一的东西 -

None of this has worked. The only thing that has was -

export PRO="/cygdrive/c/Program Files (x86)"
$ cd "$PRO"

最后,我试图找到一种方法,使我的工作变而不将引号围绕它每一次我键入变量。已经江郎才尽完全我来到这里,希望有人能帮助我。

Ultimately, I'm trying to find a way to make my variable work without placing quotes around it every single time I type the variable. Having run out of ideas entirely I came here hoping for someone to be able to help me.

推荐答案

我解决这个得到了与通配符:

I got around this with wildcards:

出口PRO =/ cygdrive / D /程序*文件/

export PRO="/cygdrive/d/Program*Files/"

这篇关于CD(1),并用空格变量(Cygwin的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆