On Thu, Mar 19, 2015 at 05:04:04PM -0500, Peng Yu wrote:
[...]
> I want to interpolate variable in a bash string variable. But the
> following code shows the spaces are not maintained. There is some
> built-in features in perl to do string interpolation. Does anyone know
> the best way to do string interpolation in bash? Thanks.
You can do that with printf:
address@hidden:~$ x=ABC y=IJK z=XYX; printf -v str '%s %s %s' "$x" "$y"
"$z"; echo "$str"
ABC IJK XYX