如何回显单引号内的变量?
echo 'test text "here_is_some_test_text_$counter" "output"' >> ${FILE}
变量在双引号字符串中扩展,但在单引号字符串中不扩展:
$ name=World
$ echo "Hello $name"
Hello World
$ echo 'Hello $name'
Hello $name
如果您可以简单地切换引号,请这样做。
如果您更喜欢使用单引号以避免额外的转义,则可以在同一参数中混合和匹配引号:
$ echo 'single quoted. '"Double quoted. "'Single quoted again.'
single quoted. Double quoted. Single quoted again.
$ echo '"$name" has the value '"$name"
"$name" has the value World
适用于您的案例:
echo 'test text "here_is_some_test_text_'"$counter"'" "output"' >> "$FILE"
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)