help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] bash variable interpolation


From: Eduardo A . Bustamante López
Subject: Re: [Help-bash] bash variable interpolation
Date: Thu, 19 Mar 2015 16:09:12 -0600
User-agent: Mutt/1.5.23 (2014-03-12)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]