sed -i 's/oldtext.*/Newtext ="'$var'"/g' file.txt
试图运行以上代码,但收到以下错误
sed: -e expression #1, char 66: unterminated `s' command
但是当我尝试不使用$var
时,它工作正常。
命令执行前
$ cat file.txt
Hi
I have code
oldtext in my script
last line
预期:
$ cat file.txt
Hi
I have code
Newtext = "New Code"
lastline