Heredoc 中的 Concat 变量

Kir*_*ril 5 string variables shell ksh concatenation

我有以下 KornShell (ksh) 脚本:

VAR='/this/is/a/path/'
DAT='01_01_2014'

cat << EOF
... what should I do here to concat variables with strings? ...
$VARfoldername$DAT
EOF
Run Code Online (Sandbox Code Playgroud)

然而,这只给了我(因为变量 $VARfoldername 被评估,这显然不存在):

01_01_2014
Run Code Online (Sandbox Code Playgroud)

我需要将 $VAR 与另一个字符串连接,然后与 $DAT 连接,这样运行脚本会导致:

/this/is/a/path/foldername01_01_2014
Run Code Online (Sandbox Code Playgroud)

she*_*ter 6

shell只有适合您的语法:

${VAR}foldername${DAT}
Run Code Online (Sandbox Code Playgroud)

IHTH