Re: Unix - Need a double incremental loop



AMBROZE wrote:

I need a counter that will increment and create output something like
this:

1 - 1
1 - 2
1 - 3
2 - 1
2 - 2
2 - 3
3 - 1
3 - 2
3 - 3

Need to set the first columns to a variable.



shell script :

#!/usr/bin/ksh
i=1
while [ "$i" -le "3" ]
do
   j=1
   while [ "$j" -le "3" ]
   do
       echo "$i - $j"
       j=`expr $j + 1`
   done
   i=`expr $i + 1`
done


Regards,

Thobias Vakayil

.