a.sh如何通过shell脚本导出变量?
#! /bin/sh
export x=/usr/local
,我们可以在命令行做source ./a
。但我需要通过shell脚本进行导出。
b.sh
#! /bin/sh
. ~/a.sh
没有错误......但$x
在命令行会显示什么。所以它没有出口。
任何想法如何使它工作?子壳
a.sh
#! /bin/sh
export x=/usr/local
-----------
[email protected]: ./a.sh
[email protected]: echo $x
[email protected]: <insert ....>
相关:http://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-and-sourcing-a-bash-scrip#176788 – lesmana