I want to accomplish the equivalent of:
list=()
while read i; do
list+=("$i")
done <<<"$input"
with
IFS=$'\n' read -r -a list <<<"$input"
What am I doing wrong?
input=`/bin/ls /`
IFS=$'\n' read -r -a list <<<"$input"
for i in "${list[@]}"; do
echo "$i"
done
This should print a listing of /
, but I'm only getting the first item.
ls
, don't. Uselist=(/*)
.