This question already has an answer here:
I am new to unix shell I am learning array by following code
source_array_list[0]="a"
source_array_list[1]="a"
source_array_list[2]="a"
source_array_list[3]="a"
source_array_list[4]="a"
source_array_list[5]="a"
source_array_list[6]="a"
source_array_list[7]="a"
a=0
while [$a -le 6]
do
echo "just before loop"
target_array[a]=source_array_list[$a]
echo "${source_array_list[$a]}"
a=`expr $a + 1`
done
Now this is not working and giving the error [0: not found.
Please guide me to solve it.
[...]
operatorwhile [ $a -le 6 ]
. – cuonglm Apr 2 at 13:04[
command, not the[0
command. – Stéphane Chazelas Apr 2 at 13:11a=`expr $a + 1`
can be changed to((a++))
. – Scott Apr 2 at 20:14