I had 3 array array1, array2, array3 where array 3 is the value of first two array. for example: FO=2.0, FF=3.5, FC=4.5 and so on. I want to give k (third loop) values of array3, like while running FO k has 2.0 value, for FF case k has 3.5 value and so on. for that i include a while loop but i have problem after i=1.
#!/bin/bash
declare -a arr1=("F" "S" "M" )
declare -a arr2=("O" "F" "C" )
declare -a arr3=(2.0 3.5 4.5 4.0 3.0 3.0 3.0 2.0 4.0)
m=0
for i in $(seq 1 ${#arr1[@]}); do
for j in $(seq 1 ${#arr2[@]}); do
l=((i*j))
while [ $m -le $l ]
do
echo "iteration"
m=$((m + 1))
#(for i=1 it will run upto j=3 and m will be 3
# but for i=2, j will again turn to 1 and l will be 2 which is less than m
# now and m will not move to 4) I want m value 4 for i=2 and j=1)
done
l=${arr3[$((m-1))]}
for k in 2.0 (array 3 value) ; do
I want to create 9 such file (i*j=array3(9)). for example, first file has F, O, 2.0 value. 2nd file has F,F, 3.5 value, third file has F, C, 4.5 value and so on.
done
done
done
I hope my question is clear, kindly help me how can i have m value like 1,2,3,4,5,6.