declare -a arr=()
find $fullfolder -type f |
while read fullfile
do
filename=$(basename "$fullfile")
ext=$([[ $filename = *.* ]] && printf %s ${filename##*.} || printf 'NONE')
arr+=($ext)
echo ${#arr[@]}
done
echo ${#arr[@]}
为什么for循环中的$ {#arr [@]}会产生正确的结果,而外面的一个不会?