i have a shell script for putting values into an array. The script is working fine for me. The problem is, if i put the array inside a for loop (between do and done), and when i try to print the array length outised the loop,i.e, after done, the values are not getting updated. Here is the sameple code;
function _read_value
{
count=0
array[0]="hi"
for ///some condition
do
count++
array[count]="hello"
done
echo ${#array[@]
}
When i try to print the length of the array at the end, it is showing the length as 1.
Any help would be appreciated.
I made some small changes in your script and its updating values and the count also comes fine.(I made change in count increment and in loop)