Replace value from input parameter

Hi Guys,

I am having a script file where in getting input parameter as string. I need to assign the variable but not able to achieve

#!/bin/bash

input=$1

replace=string_$input_string2

echo $replace

I am getting but should get string_<input_value>_string2

string_

You must protect $input by surrounding it with {} like ${input} otherwise the shell thinks
you want to expand a variable named $input_string2 which has not been defined.

2 Likes