buzzin buzzin - 1 year ago 58
Bash Question

echo command with variable and string

I have 3 variables, im trying to insert them into an echo command that contains string as well. Here is what I have.

1= "test1"
2= "test2"
3= "test3"

FileName= "WEATHERMAP"_"$1"_"STATE"_"$2"_"CITY"_"$3"

echo $FileName

I want it to
echo WEATHERMAP_test1_STATE_test2_CITY_test3

Instead I get

I know this has something to do with the
, unfortunately I need the
. Only examples I have seen are putting two variables together, or it started with a
followed by string.

Answer Source

Don't start variable names with a number.

$ a="test1"
$ b="test2"
$ c="test3"
$ FileName="WEATHERMAP_${a}_STATE_${b}_CITY_${c}"
$ echo "$FileName"