如何在shell脚本中使用变量并使用 cat<<同时转义美元字符? _ EOF _
重要的是我没有使用“或”字符。
这是我写的文字:
cat <<- _EOF_ >> "$serverconfigdir/$siteaddress"
This is a sample text! Here is my variable below!
$usethisvariable
This is another sample text! $escapethisstring show it how it looks bla bla.
_EOF_
答案 0 :(得分:2)
您需要在第二次出现时转义$
:
cat <<- _EOF_ >> "$serverconfigdir/$siteaddress"
This is a sample text! Here is my variable below!
$usethisvariable
This is another sample text! \$escapethisstring show it how it looks bla bla.
_EOF_