help with while loop or any other alternative?


i=1
while [ $i -le $1 ]
do

mm=02
dd=03
yy=2008

echo "$mm$dd$yy"

        i=$(( i+1))
        echo "$i"
done

whenever i execute the script above i will get the error below:

syntax error at line 30: `i=$' unexpected

could anyone kindly tell me what is wrong with the above script or is there any other alternative loop that i can use ? can i use a 'for loop' ?

Change increment step as below.

i=`expr $i + 1`

Which shell are you running this under? The $((...)) construct is not understood by /bin/sh

If you need this to work in Bourne shell, the classical syntax for incrementing a variable is

i=`expr $i + 1`

Note the use of backticks, and spaces around the plus.

thanks for the prompt reply.... i got it ... :slight_smile: