bash中shell和环境变量的区别

前端之家收集整理的这篇文章主要介绍了bash中shell和环境变量的区别前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
shell和环境变量有什么区别?
&安培;他们每个人的存储位置是什么?
引用 this source

Standard UNIX variables are split into
two categories,environment variables
and shell variables. In broad terms,
shell variables apply only to the
current instance of the shell and are
used to set short-term working
conditions; environment variables have
a farther reaching significance,and
those set at login are valid for the
duration of the session. By
convention,environment variables have
UPPER CASE and shell variables have
lower case names.

要列出所有环境变量,请使用printenv并列出所有shell变量,使用set。

您会注意到,环境变量存储更多的永久性值,例如:

HOME=/home/adam

哪些更改很少,而shell变量存储本地,临时,特定于shell的值,例如:

PWD=/tmp

每次更改当前目录时都会发生变化。

对于大多数实际的任务,通过向〜/ .bashrc文件添加导出VARIABLE_NAME = VALUE来设置环境值。

猜你在找的Bash相关文章