linux 中export对变量的作用

发布时间 2023-10-02 00:09:16作者: 小鲨鱼2018

001、

(base) [root@pc1 test]# ls
(base) [root@pc1 test]# echo $a           ## 测试变量a和b

(base) [root@pc1 test]# echo $b

(base) [root@pc1 test]# export a=10000    ## a加export,而b不加export
(base) [root@pc1 test]# b=10000
(base) [root@pc1 test]# echo $a           ## 正常输出都没有问题
10000
(base) [root@pc1 test]# echo $b
10000
(base) [root@pc1 test]# bash               ## 执行bash
(base) [root@pc1 test]# echo $a            ## 为什么b变量不存在了?
10000
(base) [root@pc1 test]# echo $b

(base) [root@pc1 test]#