bash how to echo array

Answer

You can define three elements array (there are no space between name of array variable, equal symbol and starting bracket):

FILES=(report.jpg status.txt scan.jpg)

This command will write each element in array:

echo ${FILES[*]}

Index in shell arrays starts from 0. So, if you want to write just first element, you can do this command:

echo ${FILES[0]}

Output: report.jpg

Do you want to process each emelent in array in loop? Here is an example:

for ELEMENT in ${FILES[@]}
do
echo File: $ELEMENT.
done

If you want to get only indexes of array, try this example:

echo ${!FILES[@]}

"${!FILES[@]}" is relative new bash's feature, it was not included in the original array implementation.