How do i add a variable as the name of the variable i want to checks value. My code is as below, when i run this i get the error:
[: A_variable: integer expression expected
I think this is because when doing an if on a variable the proper syntax should be: if [ $A_variable -eq 1 ]; but i am not able to put the dolla sign in front of my variable because i am putting a different variable in the value of my variable.
Its almost like it should be: if [ $${letter}_variable or some mix of this but i dont know what?
array=("A" "B" "C")
A_variable=1
B_variable=2
for letter in "${array[@]}"
do
if [ ${letter}_variable -eq 1 ]; then
...