title: Append elements to an array in bash
body: <p>I tried the += operator to append an array in bash but do not know why it did not work</p>
  
  <pre><code>#!/bin/bash
  
  
  i=0
  args=()
  while [ $i -lt 5 ]; do
  
      args+=("${i}")
      echo "${args}"
      let i=i+1
  
  done
  </code></pre>
  
  <p>expected results</p>
  
  <pre><code>0
  0 1
  0 1 2
  0 1 2 3
  0 1 2 3 4
  </code></pre>
  
  <p>actual results</p>
  
  <pre><code>0
  0
  0
  0
  0
  </code></pre>
  
  <p>Any help would be appreciated.</p>