使用bash_profile设置环境变量,但echo不返回

sph*_*ton 1 bash environment-variables

最近在mac上,我设置了一个环境变量,以便它出现在一个新的shell中.今天打开一个shell,即使我设置它也不再出现在新的shell中.我一直在使用:

export "AVARIABLE=example" >>~/.bash_profile
Run Code Online (Sandbox Code Playgroud)

到目前为止我运行时工作正常:

echo $AVARIABLE
Run Code Online (Sandbox Code Playgroud)

我只是得到一个空白的行,好像它不存在.

这种情况在我尝试永久设置环境变量的任何时候都会发生.我看不出我做错了什么?

提前致谢

Ami*_*mit 6

echo在命令中缺少一个.试试这个然后来源~/.bash_profile:

echo export "AVARIABLE=example" >> ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)

您还必须.profile在对其进行更改后获取源.

source ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)