Not sure how to explain this but I am trying to create a variable on the fly of an existing variable. But not sure how to explain it. I have tried many different ways bit its now about to blow my mind.
# existing variable
count_completed=10
count_failed=2
showCount() {
if [ "$1" == "completed" ]; then
echo ${1^^} count is $count_${1,,}
fi
}
showCount "failed"
I've tried to create another variable and escaped the dollars and then tried echo that variable, but it didn't work
newvar=\$count_\${1,,}
echo ${1^^} $newvar
Im not sure what I'm doing wrong... :) its a very unique issue; Can't find any examples of what I'm looking for or what I should be asking for...