I am trying to create a set of each 3 values within a range using Shell script.
Range of values : 512 -885
Column difference: 12
Column increment: 3
512 524 536
515 527 539
518 530 542
......
860 872 884
863 875 513 --> Column 3 Reset
866 878 516
869 881 519
872 884 522
875 513 525 --> Column 2 Reset
878 515 528
881 518 531
884 521 534
513 524 537
....
Shell Script:
#!/bin/bash
start=512
end=885
incr=12
col1=$start
col2=$(($col1+$incr))
col3=$(($col2+$incr))
colincr=3
for z in {1..50}
do
if [ $col1 -gt $end ]
then
col1=$(($(($col1 % $end))+$start-1))
fi
if [ $col2 -gt $end ]
then
col2=$(($(($col2 % $end))+$start-1))
fi
if [ $col3 -gt $end ]
then
col3=$(($(($col3 % $end))+$start-1))
fi
printf '%-4s%-4s%-4s\n' $col1 $col2 $col3
col1=`expr $col1 + $colincr`
col2=`expr $col2 + $colincr`
col3=`expr $col3 + $colincr`
done