Complex variable assignment

Hi,
I have a requirement as follows, need to call the format of ${$var} form.

For example, i am taking a variable.

  count=1, 
  ((LIMIT_$count=$count + 1))

Now i have to echo this variable LIMIT_$count. (This is in a loop..)
echo ${LIMIT_$count} - displays as a syntax error.

Can anyone please help me with this.

Thanks,
Abhishek S.

count=1
while [ $count -le 10 ]
do
    echo $count
    let count+=1   #or   count=$(( $count + 1 ))
done

I think this is what you want:

Use 'eval'.

Ex:

#!/usr/bin/ksh93

COUNT=1
eval LIMIT_${COUNT}=$(($COUNT + 1))

echo $LIMIT_1
eval echo \${LIMIT_$COUNT}

Output:

>
2
2
1 Like

Hey purdym,
Sorry for the late response, but thats the exact thing i was looking for. Thanks a lot again man.. !! It works for me..