I have an input file which is comma separated lines, which I need to assign to the keys as mentioned below, I have tried assigning them but I'm not able to figure out how to assign them separately yet group together as shown below expected result.
I would really appreciate if someone can help me with this, I have not used the arrays or comma separated values before and having issue to get it to work.
Input file
10.219.196.0,15gb,Azure Cloud
10.219.196.0,55gb,Google Cloud
10.219.196.0,54gb,AWS Cloud
I have to assign the IP address with key IP, size with key size and the cloud name with key platform, the tricky part is I have to assign it this way
Expected Result
IP1=10.219.196.0
Size1=15gb
Platform1=Azure Cloud
IP2=10.219.196.0
Size2=15gb
Platform2=Google Cloud
IP3=10.219.196.0
Size3=15gb
Platform3=AWS Cloud
Solution I have tried is as below
i=1;
for $line in `cat file`
do
my_ary=$line
echo "IP$i=${my_ary[0]}"\n
echo "Size$i=${my_ary[1]}"\n
echo "platform$i=${my_ary[2]}"\n
$i++
done
Please let me know how can I fix this to get the expected result.