If there is a colon (:) in the directory name, how could I add it to $PATH? [duplicate]

Deadly 提交于 2019-12-01 16:41:57

问题


I am using mac os x, and I have some trouble setting the $PATH env. If the directory name is /path/to/add/a:b/bin, how can I add this directory to $PATH which is separated by :?


回答1:


As far as I know, you can't. The obvious way to escape a : character in $PATH would be to use a backslash, but a quick experiment with Bash on Linux indicates that it doesn't work. OSX might behave differently, but I suspect you'd have the same problem.

Your best bet is to rename the directory. If it really needs to have that name, you can create a symbolic link and add that to your $PATH:

 $ cd /path/to/add
 $ ln -s a:b a_b
 $ PATH="$PATH:/path/to/add/a_b/bin"


来源:https://stackoverflow.com/questions/21641294/if-there-is-a-colon-in-the-directory-name-how-could-i-add-it-to-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!