シェル変数商標

シェル変数商標

私はHTMLリンクを含む電子メールを送信する簡単なbashスクリプトを書いた。

#!/bin/bash
ASS=10
sendmail [email protected] <<EOF
Subject: Simple title
<html>
<body>
this is just a link
URL: <a href="http://test.site/index?redirect=tail_$ASS_Tail\$1&noAUTO=1">Go to site</a>
</body>
</html>
EOF

ところで、メールが届きましたが、$ASSリンクが挿入されず、次のような内容が表示されます。 http://test.site/index=tail_$1&noAUTO=1を解決するには?

ベストアンサー1

_これは、変数が有効な合成文字であるためです。あなたは:

URL: <a href="http://test.site/index?redirect=tail_$ASS_Tail\$1&noAUTO=1">

ASS_Tailここで、変数名は、有効な最大文字数(最大)から始めて考慮されます。\ASS

${}名前の後に有効な文字がある場合は、変数名宣言を囲む必要があります。

URL: <a href="http://test.site/index?redirect=tail_${ASS}_Tail\$1&noAUTO=1">

おすすめ記事