[Solved] Array from a file


Quotes fix everything:

while read line
do
    IFS=':' read -ra ADDR <<< "$line"
    echo ${ADDR[0]}
    echo ${ADDR[1]}
done < file.txt

Quoting the variable "$line" is what made the difference. If you’re not getting the line with “C:c”, it’s probably because your file is missing a final newline.

solved Array from a file