How to check environment variable in a linux subsh

2019-08-26 16:14发布

问题:

I have a config file which I can $source and check the variable values in it. However, I do not want to contaminate my current shell environment while still want to check the value of the variables.

Any suggestions?

回答1:

Just start a second shell.

[root@feaf38f55954 ~]# cat envars
export BOOGER='yuck'
[root@feaf38f55954 ~]# env | grep BOOGER
[root@feaf38f55954 ~]# bash
[root@feaf38f55954 ~]# source envars
[root@feaf38f55954 ~]# env | grep BOOGER
BOOGER=yuck
[root@feaf38f55954 ~]# exit
exit
[root@feaf38f55954 ~]# env | grep BOOGER
[root@feaf38f55954 ~]#


标签: linux shell