linux shell global variable does not available in another window terminal

后端 未结 1 1611
暖寄归人
暖寄归人 2021-01-23 17:03

I open tow terminal windows in my linux OS. In one window, I type the command

export a=10

but in another window, I enter

echo          


        
相关标签:
1条回答
  • 2021-01-23 17:56

    When you export an environmental variable, the child processes of the shell (e.g.: the commands executed by the shell) do obtain a copy of that exported variable.

    Shells running in two different terminals/windows do not fulfill this relationship in terms of processes.

    If you want to set an environmental variable, so that every running shell will obtain a its own instance of the variable, consider defining it in .bashrc (assuming you are using bash). However, you won't be able to use this variable as a one "being shared" by all the running shells (each shell has its own copy of the variable).

    0 讨论(0)
提交回复
热议问题