BASH: 尝试在另一行继续一个字符串而不引入白色 space

BASH: Trying to continue a string on another line without introducing white space

我有一个 BASH 脚本,其条件与此类似:

dirImg="/var/log/junk"
sizeLimitMsg="1 gig"

if [ 0 == "$fileSize1" ];then
    echo "All directories under $dirImg are within the allowed\
    $sizeLimitMsg size limit" >> $emailBody
else
    #do something else
fi

它产生额外的白色输出space:

All directories under /var/log/junk are within the allowed   1 gig size limit

我猜额外的和不需要的白色 space 是由于在上面的条件中缩进了变量 $sizeLimitMsg。

无论如何我都可以继续该行并缩进该代码而不会得到额外的和不需要的白色space?

不要在引号中包含缩进:

echo "All directories under $dirImg are within the allowed" \
     "$sizeLimitMsg size limit"

选择:

printf "%s %s\n" "All directories under ${dirImg} are within the allowed" \
    "${sizeLimitMsg} size limit" >> "${emailBody}"