[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] bash variable interpolation
From: |
Peng Yu |
Subject: |
[Help-bash] bash variable interpolation |
Date: |
Thu, 19 Mar 2015 17:04:04 -0500 |
Hi,
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.
~$ cat main.sh
#!/usr/bin/env bash
x=ABC
y=IJK
z=XYZ
str='$x $y $z'
eval echo "$str"
~$ ./main.sh
ABC IJK XYZ
--
Regards,
Peng