On Thu, Mar 19, 2015 at 08:03:01PM -0400, Dave Rutherford wrote:
> On Thu, Mar 19, 2015 at 7:37 PM, Peng Yu <address@hidden> wrote:
> > On Thu, Mar 19, 2015 at 5:42 PM, Eric Blake <address@hidden> wrote:
> >> On 03/19/2015 04:04 PM, Peng Yu wrote:
> >>> I want to interpolate variable in a bash string variable. But the
> >>> following code shows the spaces are not maintained.
> >>
> >> Insufficient quoting on your part.
> >>
> >>> 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.
>
> I feel dumb. What is meant by `string interpolation'?
I think I first saw that term used in Perl, meaning to expand (perl)
variables in place in a string, but I didn't remember it or recognize
it in this context until a few posts in.
> > The real problem is that I want to replace some bash variables in a
> > file and then print the output.
A common term for expanding variables or tokens in a file is 'template
expansion'. I shy away from eval, so would probably treat the variables
as string tokens and subsitute the values in a loop.
Ken