我想在 ~/.profile
末尾回显以下行使用 tee 命令的文件:export PATH="$HOME/.local/bin:$PATH"
为此,我的 bash 脚本如下所示
#!/bin/bash
path_env="export PATH="$HOME/.local/bin:$PATH""
echo $path_env| sudo tee -a $HOME/.profile > /dev/null
但每当我执行脚本时,它也会执行 $PATH 和 $HOME 值并将其插入
~./profile
我不想要的文件。我只希望 bash 脚本传递确切的行,而不是用自己的值替换 $PATH 和 $HOME。
最佳答案
I only want the exact line to be passed by the bash script instead of replacing $PATH and $HOME with its own values.
哦,对了,所以不要扩展它。报价。
path_env='export PATH="$HOME/.local/bin:$PATH"'
echo "$path_env" | sudo tee -a "$HOME/.profile" > /dev/null
关于linux - Bash 脚本 tee 命令语法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61477461/