How to check environment variable in a linux subsh

2019-08-26 16:16发布

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?

标签: linux shell
1条回答
放荡不羁爱自由
2楼-- · 2019-08-26 16:20

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 ~]#
查看更多
登录 后发表回答