I want to use a variable within a variable name and can't figure out how to do it. Here's what I intend to do
if [some condition]; then
id="A"
else
id="B"
fi
${id}_count=$((${id}_count + 1))
Where, if the condition is met it would be
A_count=$(A_count + 1))
or if the condition is not met
B_count=$(B_count + 1))
The ${id}
is obviously not working. I just tried it this way because it works this way in strings.
(No, it's not the only line I want to use $id in. Otherwise I would put it in the if-condition directly.)
How would it work within a variable name?
Thanks, Patrick