如何在Ubuntu的Shell脚本中运行.profile [英] How to run .profile inside a shell script in ubuntu
本文介绍了如何在Ubuntu的Shell脚本中运行.profile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在运行一个脚本,该脚本在.profile文件中回显环境变量,并且比我正在运行该脚本,但出现以下错误
I am running a script which is echoing the environment variables in .profile file and than I am running the script, but I am getting following error
我尝试了以下操作:
node@node-virtual-machine:~$ cat env.sh
#!/bin/bash
echo 'export JAVA_HOME=/home/node/jdk1.6.0_45' >> /home/node/.profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /home/node/.profile
cd /home/node/
source .profile
node@node-virtual-machine:~$ sh env.sh
sudo: source: command not found
如何在脚本中执行.profile?
How to execute .profile within a script?
推荐答案
而不是:
sh env.sh
您应该运行:
bash ./env.sh
在旁边,而不是:
source .profile
使用:
source ~/.profile
这篇关于如何在Ubuntu的Shell脚本中运行.profile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文