[clue-tech] increment weather

David L. Willson DLWillson at TheGeek.NU
Mon Feb 22 21:34:41 MST 2010


I have a loop-counter that I want to increment from within the loop, having found that the next two items in the array I'm iterating through belong to me.  How can I do that?

This illustrates my problem:

for i in $(seq 10)
do
   echo $i
   if [ $i -eq 4 ]
   then
      echo -n "i is $i.  next two are: "
      i=$(($i+1))
      echo -n "$i and "
      i=$(($i+1))
      echo "$i."
   fi
done

Notice that the outer loop goes right back to the i that it knows and loves, ignoring my in-loop increments.

David L. Willson
Trainer, Engineer, Enthusiast
MCT MSCE N+ A+ L+ NovellCLA LPIC-1
tel://720.333.LANS
Freeing people from the tyranny (or whatevery) of Microsofty-ness, one at a time.


More information about the clue-tech mailing list