I'm not a bash expert either, but you could also consider using the readarray builtin in place of your for loop - something like
Code:
$ readarray -t array < <(ls -la /tmp)
might work for you - e.g.
Code:
$ readarray -t array < <(ls -la test)
$
$ for f in "${array[@]}"; do echo "$f"; done
total 12
drwxr-xr-x 3 steeldriver steeldriver 4096 Jun 23 19:31 .
drwxr-xr-x 40 steeldriver steeldriver 4096 Jun 22 19:30 ..
drwxr-xr-x 2 steeldriver steeldriver 4096 Jun 14 21:27 dir
-rw-r--r-- 1 steeldriver steeldriver 0 Jun 23 19:31 file with space
$
$ echo ${array[3]}
drwxr-xr-x 2 steeldriver steeldriver 4096 Jun 14 21:27 dir
Bookmarks