But it shows how to pass a variable outside of a while loop in bash:
find . -type f -size +1000k -print0 | { while IFS= read -r -d '' file; do FOO="$FOO `stat -r "$file" | gawk '{print $8}'| tr '\n' ' '`" # Return the size without a new line at the end FOO="$FOO `echo \"$file\"`\n" # Return the file name WITH a new line at the end done echo -ne "$FOO" | sort -rn # return sorted results }