簡體   English   中英

Shell同時使用變量和轉義美元字符

[英]Shell use variable and escape dollar character at the same time

如何使用cat << _ EOF _在 shell 腳本中同時使用變量和轉義美元字符?

重要的是我沒有使用 " 或 ' 字符。

這是我要寫的文字:

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_

您需要在第二次出現時轉義$

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_

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM