title: bash populate an array in loop
body: <p>How can i populate an array in loop? I'd like to do something like that:</p>
  
  <pre><code>declare -A results
  
  results["a"]=1
  results["b"]=2
  
  while read data; do
  results[$data]=1
  done
  
  for i in "${!results[@]}"
  do
    echo "key  : $i"
    echo "value: ${results[$i]}"
  done
  </code></pre>
  
  <p>But it seems that I cannot add anything to an array within for loop. Why?</p>