for ((i=0; i<4; i++)) do for ((j=1000; j<20000; j=j*2)) do SUM=0 for ((k=0; k<$1; k++)) do R=$(a.out $i $j) ARR=($R) #echo $ARR #echo "TIME: ${ARR[2]}" SUM=$(echo "$SUM + ${ARR[2]}" | bc -l) #echo "SUM $SUM" done AVG=$(echo "$SUM / $1" | bc -l) echo "$i $j AVERAGE over $1: $AVG" done done