[clue-tech] increment weather

Dennis J Perkins dennisjperkins at comcast.net
Mon Feb 22 22:02:26 MST 2010


David L. Willson wrote:
> 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.
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://cluedenver.org/mailman/listinfo/clue-tech
>
>   
Try using this:  for (( i = 0; i < 10; i++ ))
do

done

The spaces are not a mistake.  This form allows them.


More information about the clue-tech mailing list