[Solved] Array from a file

[ad_1]

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.

[ad_2]

solved Array from a file