While within while is not working in Korn shell

Hi all,

I tried to execute a while within another while, but not working. Any suggestions? Thanks in advance


#!/bin/ksh
 
typeset -i i=1
typeset -i j=1
 
while [[ $i -lt 4 ]]
do
   while [[ $j -lt 3 ]]
   do
      print i = $i j= $j
      (( j=j+1 ))
   done
   (( i=i+1))
done

I get result is

i = 1 j= 1
i = 1 j= 2

j remains at value 3 once it reaches it. Reset to one just before the j loop.

1 Like

You forgot to reset j

   j=1
   while [[ $j -lt 3 ]]
1 Like

Thanks

Moderator comments were removed during original forum migration.