title: bash + for loop + output index number and element
body: <p>This is my array:</p>
  
  <pre><code>$ ARRAY=(one two three)
  </code></pre>
  
  <p>How do I print the array so I have the output like: <code>index i, element[i]</code> using the <code>printf</code> or <code>for</code> loop I use below</p>
  
  <pre><code>1,one
  2,two
  3,three
  </code></pre>
  
  <p>Some notes for my reference</p>
  
  <p>1 way to print the array: </p>
  
  <pre><code>$ printf "%s\n" "${ARRAY[*]}"
  one two three
  </code></pre>
  
  <p>2 way to print the array </p>
  
  <pre><code>$ printf "%s\n" "${ARRAY[@]}"
  one
  two
  three
  </code></pre>
  
  <p>3 way to print the array </p>
  
  <pre><code>$ for elem in "${ARRAY[@]}"; do  echo "$elem"; done
  one
  two
  three
  </code></pre>
  
  <p>4 way to print the array </p>
  
  <pre><code>$ for elem in "${ARRAY[*]}"; do  echo "$elem"; done
  one two three
  </code></pre>
  
  <p>A nothe way to look at the array </p>
  
  <pre><code>$ declare -p ARRAY
  declare -a ARRAY='([0]="one" [1]="two" [2]="three")'
  </code></pre>