When I declare an array in bash $ ARRAY=('ele1' ele2') I can append an element to it with $ ARRAY+=('ele3').
echo ${ARRAY[@]}
ele1 ele2 ele3
However, inside a script in a while loop I don't get it to work:
FOUNDFILES=$(ls -lA)
LINE_CNT=1
ARRAY=()
echo -e "$FOUNDFILES" | while read line
        do
                ARRAY+=("test")
                LINE_CNT=$((LINE_CNT+1))
        done
echo "${ARRAY[@]}"
echo $LINE_CNT
LINE_CNT variable delivers the amount of files that were found, but my array stays empty.
What am I doing wrong?
 
    