Hi there - am newish to shell scripting and would appreciate some advice on this...
Am trying to use what I have seen called 'compound variables' in other langs but with no success in my shell script. This is the kind of thing I'm trying to do:
base_val=123
stop=3
x=1
while [ $x -le $stop ]
do
array_var[$x] = `expr $base_val + $x`
echo $x $array_var[$x]
x=`expr $x + 1`
done
The value of x is being incremented, but it is not being substituted as an index in the array variable called array_var. Here's the output:
./t2.ksh[8]: array_var[1]: not found
1 [1]
./t2.ksh[8]: array_var[2]: not found
2 [2]
./t2.ksh[8]: array_var[3]: not found
3 [3]
Is this completely the wrong approach, or is it an issue with the syntax?. What's the best way to achieve this?
Thanks in advance,
Neemic........: