Incrementing variable in for

Hi,
want to increment a variable in a for loop like this:

for (( c=$total-1; c>=0; c-- ))
do
if [ $maximo <= $res$c ];            
then
maximo=$valores
fi
done

But it gives the error:
No such file or directory

How can i do this only incrementing the c variable?

Thanks

I think c=$total-1 maybe the problem.

try:-

x=`expr ${total} - 1`
for (( c=$total; c>=0; c-- ))

Not sure what you mean - certainly looks like you're decrementing 'c'.

if [ $maximo <= $res$c ];

is a mixture of "bash" and sh/ksh...so either:

if [ $maximo -le $res$c ];

or

if(( $maximo <= $res$c ));

I want to increment the res$c so i can get a variable like:
$res1
$res2
$res3
$res4

Sounds like you should use an array.

Use eval, an example:

i=5

eval res$i="ABC"
echo $res5

Let me explain better. I have this values:

res=0.0032
res1=0.41234
res2=0.42342
res3=0.4523
res4=0.23123
res5=0.12311

and i want to do a for so that i can get the values inside this variables:

c=6
maximo=$res
for (( c=$total-1; c>=0; c-- ))
do
if [ $maximo <= $res$c ];            
then
maximo=$valores
fi
done

But what when i do that it put the value of res just shows the value of the value res with the value of c in the front

---------- Post updated at 08:08 AM ---------- Previous update was at 07:25 AM ----------

I solved it. I done something like this:

maximo=$res
########################################
for (( c=5; c>=0; c-- ))
do
variavel=res$c 
varx=${!variavel}
echo $varx
if(( $maximo <= $varx ));            
then
maximo=$valores
fi
done
res=0.0032
res1=0.41234
res2=0.42342
res3=0.4523
res4=0.23123
res5=0.12311

c=5
maximo=$res
while [ c -gt 0 ]
do
  eval "var=\$res$c"
  maximo=$(echo $var $maximo | awk '{print ($1>$2?$1:$2)}')
  c=$(( $c - 1))
done

echo $maximo