I want to put the files of the current directory in an array and echo each file with this script:
#!/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]}
The output:
echo.sh
echo.sh read_output.sh
Does anyone know why only the first element is printed in this for loop?