Nested loop in Unix

Hi,
I have the following script which is two while loops, but it is working only for the Inner loop without going back to the outer loop.

the aim of this script is to remove data files from memory after each five times for each setting of the rotate parameter

#!/bin/csh
set hdir = /home/stud/s3192861/researchM
set collbig = $hdir/small
set collsmall = $hdir/tiny
cd $hdir
@ test = 1
@ test2 = 1
while ($test < 10)
while ($test2 < 5)
date > rotation.big.$test.$test2
time $hdir/tree -rotate $test2 -vocab $collbig >> results/rotation.big.$test.$test2
@ test2 = $test2 + 1
end
@ test = $test + 2
./flushit $collbig
end

Any one can help please??

Hi.

You need to set test2 inside the first while loop otherwise it will be 4 at the start of the second iteration of the loop...

#!/bin/csh
set hdir = /home/stud/s3192861/researchM
set collbig = $hdir/small
set collsmall = $hdir/tiny
cd $hdir
@ test = 1
while ($test < 10)
  @ test2 = 1
  while ($test2 < 5)
    date > rotation.big.$test.$test2
    time $hdir/tree -rotate $test2 -vocab $collbig >> results/rotation.big.$test.$test2
    @ test2 = $test2 + 1
  end
  @ test = $test + 2
  ./flushit $collbig
end