关于设置环境变量的问题

thethefighter 2006-03-01 12:17:38
我在shell中设置环境变量
vi test.sh
export show=thisshow
推出vi
执行test.sh后再执行echo $show
为什么thisshow显示不出来?
...全文
83 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fierygnu 2006-03-01
  • 打赏
  • 举报
回复
执行test.sh,是子进程,不能更改父进程的环境。
用. test.sh执行就可以了,相当于在本shell里执行test.sh里的命令。
thethefighter 2006-03-01
  • 打赏
  • 举报
回复
喔,是这样。谢谢
fierygnu 2006-03-01
  • 打赏
  • 举报
回复
.profile,不是profile。或者.bash_profile。
/etc/profile,影响全部用户。
thethefighter 2006-03-01
  • 打赏
  • 举报
回复
多谢va,果然可以。
还有问题,我在$HOME下的profile加入export show=thisshow
为什么没用?

echo $HOME
/opt/sybase
pwd
/opt/sybase
echo $is
bash
ls profile
profile

vi profile

#
# Never run any DBA or SA under for sybase as root
#
if [ `id -u` -eq 0 ]; then
echo "This account should not be ran with uid = 0"
exit 1
fi

export show=thisshow





23,222

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧