为什么我不能永久导出变量?

fee*_*ree 5 command-line

为了永久导出变量,我们可以在以下文件中编写导出命令:

~/.profile
~/.bash_profile
/etc/profile 
Run Code Online (Sandbox Code Playgroud)

在我的情况下, ~/.bash_profile不存在,因此我在其他两个文件中导出变量:

export country=UK
Run Code Online (Sandbox Code Playgroud)

我现在遇到的问题是我定义的变量 ( country) 对于系统来说仍然是未知的。我在想接下来我该怎么做。

squ*_*org 4

配置文件仅在您登录时读取,您是否尝试过登录 shell bash -loginbash -注销然后重新登录或只是简单地重新启动?

如果需要,您可以.bashrc在每次生成shell 时使用它。