title: Expanding a bash array only gives the first element
body: <p>I want to put the files of the current directory in an array and echo each file with this script:</p>
  
  <pre><code>#!/bin/bash
  
  files=(*)
  
  for file in $files
  do
      echo $file
  done
  
  # This demonstrates that the array in fact has more values from (*)
  echo ${files[0]}  ${files[1]} 
  
  echo done
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>echo.sh
  echo.sh read_output.sh
  done
  </code></pre>
  
  <p>Does anyone know why only the first element is printed in this for loop?</p>