1、

COUNTER=0
while [ $COUNTER -lt 3 ]
do
    COUNTER=`expr $COUNTER + 1`
    echo $COUNTER
done

注:expr用法