字符串拼接

基本类型 / 字符串

s1="three"
s2="two"

#strings are joined just by writing them side by side;
#no spaces around =, otherwise s3 is run as a command
s3="$s1, $s2"
#s3 is "three, two"

#+= appends to the end
s3+=", one"
#s3 is "three, two, one"

sGo="$s3, go!"
#sGo is "three, two, one, go!"

#printf -v joins by a format into a variable
printf -v sFormat '%s, %s' "$s3" "go!"
#sFormat is "three, two, one, go!"

echo "sGo is $sGo"
echo "sFormat is $sFormat"