I’m trying to learn a few things about scripting and Linux systems, so I started learning `bash` scripting.

For an exercise, I’m trying to program a script that would install all programs that user chooses.

I worked out a skeleton of installation part, but I’m stuck at determining users answer.

Here is my code:

```
#!/bin/bash

declare -a instal_list=("Gimp" "VLC" "Gedit")

for ((i=0; i<3; i++))
do

echo "Do you want to install ${instal_list[i]} ?"
echo
read answer_${instal_list[i]}

if [[ $answer_${instal_list[i]} == "yes" ]] || [[ $answer_${instal_list[i]} == "Yes" ]] || [[ $answer_${instal_list[i]} == "YES" ]];
then

 instal+=" ${install_list[i]}"

fi

done

```

My problem is in my `if` statement. Inside of it, I’m trying to evaluate if users answer is yes. Problem is in `answer_${instal_list[i]}` variable.

I don't know how to explain what I mean, so I will try to explain it on example.

Example :

* We run the script, and the script asks us if we want install Gimp.
* We say yes, and the script stores that answer in variable "answer\_${instal\_list[1]}" ("answer\_Gimp").
* My problem is when I try to call back that variable ("answer\_Gimp"). 
= To call it I use "$answer\_${instal\_list[1]}" line, but the shell doesn’t recognize that command as answer\_Gimp.

So how can I call back variable `answer_${instal_list[1]}` so that shell would recognize it as "answer\_Gimp"?
['https://Stackoverflow.com/questions/23576155', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3622290/']
```
thing="Gimp"
answer_Gimp="Yes"

variableName="answer_$thing"
echo "The value of $variableName is ${!variableName}"

```
If you have bash version 4, you can use an associative array:

```
declare -a instal_list=("Gimp" "VLC" "Gedit")
declare -a to_install
declare -A answers

for prog in "${instal_list[@]}"; do
    read -p "Do you want to install $prog? [y/n] " answer["$prog"]
    if [[ "${answer["$prog"],,}" == y* ]]; then
        to_install+=( "$prog" )
    fi
done

echo you want to install:
printf "   %s\n" "${to_install[@]}"

```

Looking at that, I don't see why you need to keep the answers in an array. But if you do, that's how you'd do it.