Replace the comma-separated string with an array as soon as feasible. If it's a hard-coded string, that's trivial:
ip1=(Ok1 ok2 ok3)
If it's from an external source (say, a command-line argument or read from a file), use read:
ip1s="Ok1,ok2,ok3"
IFS=, read -a ip1 <<< "$ips1"
Once you have an array, you can use array syntax for iteration:
for i in "${ip1[@]}"; do
echo "$i"
done
If you have multiple arrays you want to iterate in lockstep, you can iterate over the keys of the arrays:
for i in "${!ip1[@]}"; do
echo "${ip1[i]}"
echo "${ip2[i]}"
done
(This ignores the possibility of sparse arrays, but you have to work to get those. In practice, arrays with n elements usually have keys 0, 1, ... n-1.)
ipas if it were an array. Butip1andip2are strings, so${ip[@]}is probably not what you think it is.