This is what I tried:
vara=${varb}_count
(( vara += 1 ))
Thanks for help
This is what I tried:
vara=${varb}_count
(( vara += 1 ))
Thanks for help
hmm.... this is one confusing explanation.
what are you trying to do?
I'm iterating through a list of test names, each has two associated variables: the number of times the test passed, and the number of times the test ran
varb would be the name of the test at the current iteration (e.g. test04)
when I check if the test passed, I need to increment the corresponding count variable (for example, if at this iteration the test name is test04, the associated count variable name is test04_count)
Thus, the name of the variable to be incremented is composed from the value of one variable (varb) and "_count"
The question is how to increment that variable (vara)
here's something to start with as I'm still a bit confused....
#!/bin/ksh
typeset num;
for iter in 1 2 3 4 5 6 7 15 123
do
varb="test$(printf "%02d" ${iter})"
vara="${varb}_count"
# increment vara
#
num=$(printf "%02d" $(( $(echo "${vara}" | sed -e 's/^[^0-9]*\([0-9][0-9]*\)_.*/\1/') + 1 )) )
echo "varb->[${varb}] vara->[${vara}] incrementedNum->[${num}] incrementedVarA->[test${num}_count]"
done;
after some adjustments, I got what I needed.
Thanks a lot.