My Code :
--------------------------------------------
#!/bin/bash
for i in `echo server1 server2`
do
eval ${i}_name = "apache"
echo ${i}_name
done
--------------------------------------------
Current output :
>./test.sh
./test.sh: line 5: server1_name: command not found
server1_name
./test.sh: line 5: server2_name: command not found
server2_name
--------------------------------------------
Expected output :
apache
apache
--------------------------------------------
Basically, I need to have variable name depending on arguments passed in for loop etc.
Please assist.