bash 如何在 OS X 上查看 $PATH 变量的当前值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14617041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I see the current value of my $PATH variable on OS X?
提问by Karoh
$ $PATH
$$路径
returns:
返回:
-bash: /usr/local/share/npm/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin: No such file or directory
-bash: /usr/local/share/npm/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Library/ Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin : 无此文件或目录
This seems quite ugly and might be giving me issueswith getting Homebrew up and running as well.
回答by HeatfanJohn
You need to use the command echo $PATH
to display the PATH variable or you can just execute set
or env
to display all of your environment variables.
您需要使用该命令echo $PATH
来显示 PATH 变量,或者您可以只执行set
或env
显示所有环境变量。
By typing $PATH
you tried to run your PATH variable contents as a command name.
通过键入$PATH
您尝试将 PATH 变量内容作为命令名称运行。
Bash displayed the contents of your path any way. Based on your output the following directories will be searched in the following order:
Bash 以任何方式显示您的路径的内容。根据您的输出,将按以下顺序搜索以下目录:
/usr/local/share/npm/bin
/Library/Frameworks/Python.framework/Versions/2.7/bin
/usr/local/bin
/usr/local/sbin
~/bin
/Library/Frameworks/Python.framework/Versions/Current/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/opt/X11/bin
/usr/local/git/bin
To me this list appears to be complete.
对我来说,这个列表似乎是完整的。
回答by paxdiablo
By entering $PATH
on its own at the command prompt, you're trying to runit. This isn't like Windows where you can get your path output by simply typing path
.
通过$PATH
在命令提示符下单独输入,您正在尝试运行它。这与 Windows 不同,在 Windows 中,您只需键入path
.
If you want to see what the path is, simply echo it:
如果您想查看路径是什么,只需回显它:
echo $PATH
回答by Alexandr
Use the command:
使用命令:
echo $PATH
and you will see all path:
你会看到所有的路径:
/Users/name/.rvm/gems/ruby-2.5.1@pe/bin:/Users/name/.rvm/gems/ruby-2.5.1@global/bin:/Users/sasha/.rvm/rubies/ruby-2.5.1/bin:/Users/sasha/.rvm/bin:
/Users/name/.rvm/gems/ruby-2.5.1@pe/bin:/Users/name/.rvm/gems/ruby-2.5.1@global/bin:/Users/sasha/.rvm/rubies/ ruby-2.5.1/bin:/Users/sasha/.rvm/bin:
回答by Lam Do
for MacOS, make sure you know where the GO install
对于 MacOS,请确保您知道 GO 的安装位置
export GOPATH=/usr/local/go
PATH=$PATH:$GOPATH/bin