Why does the values not get set in the array[@] and subsequently $i. This question has been asked before and I am aware of that , the reason I am asking here is because it doesn't work. Before you jump to mark this as duplicate, please can you let me know why it doesn't work? Not sure what is wrong here.
#!/bin/bash
DEALS=1739719, 1714630, 1733697, 1723940, 1666257, 1665239, 1674778, 1720875, 1674777, 1763086, 1735526, 1845881
IFS=', ' read -ra array <<< "$DEALS"
for i in ${array[@]}
do
echo $i
done
DEALS=1739719, 1714630, 1733697,...isn't an assignment at all. It runs a command called1714630,with the first argument1733697,and the variableDEALS=1739719,temporarily set in the environment.${array[@]}has all the bugs of${array[*]}; it needs to be quoted,"${array[@]}", to be accurate. Similarly,echo $ishould beecho "$i"DEALS=...be an assignment, quote the right-hand side.