[英]Setting Path variable using shell scripting - Using a shell variable
I have variable difine as SCRPT_PATH="/home/dasitha"
I need to add this path to .bashrc file using shell scirpt. 我有变量difine作为
SCRPT_PATH="/home/dasitha"
我需要使用shell scirpt将此路径添加到.bashrc文件中。
What I tired was something like this. 我累的是这样的。
echo 'export PATH=$PATH:$SCRPT_PATH")' >> /root/.bashrc
After opening my .bashrc file it looks like this 打开我的.bashrc文件后,它看起来像这样
export PATH=$PATH:$SCRPT_PATH")
What I actually need is export PATH=$PATH:/home/dasitha. 我真正需要的是export PATH = $ PATH:/ home / dasitha。 How should I do this by changing the shell script?
我应该如何通过更改Shell脚本来做到这一点?
You've got the wrong quotes (in addition to a spurious looking parenthesis and quote mark). 您使用了错误的引号(除了带有虚假的括号和引号)。 You're looking for something more like
您正在寻找更像的东西
echo "export PATH=$PATH:$SCRPT_PATH" >> /root/.bashrc
Here's a quick example that demonstrates quoting: 这是一个演示引用的简单示例:
krismatth@earth ~$ echo $HOME
/Users/krismatth
krismatth@earth ~$ echo '$HOME'
$HOME
krismatth@earth ~$ echo "$HOME"
/Users/krismatth
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.