problem with while loop in BASH shell

I have file named script1 as follows:

#!/bin/bash
count="0"
echo "hello"
echo "$count"
while [ $count -le 5 ]
do
echo "$count"
count=`expr $count + 1`
done
-----------
when I run it, I get

./script1: line 9: syntax error near unexpected token `done'
./script1: line 9: `done'

I have typed this in Textpad and I am running it in Cygwin..

I checked in textpad and there is no newline at the end of done..

also to invoke the script i am using ./script1 on the command prompt in the terminal window

Well it works for me.

bash-3.00$ cat x
#!/bin/bash
count="0"
echo "hello"
echo "$count"
while [ $count -le 5 ]
do
echo "$count"
count=`expr $count + 1`
done

bash-3.00$ ./x
hello
0
0
1
2
3
4
5
bash-3.00$

Could be a problem with the file format, try to remove the CR's with:

tr -d '\r' < your_file > newfile

ok it worked after removing the carriage returns!
thanks a ton..

ok that helped but now i have this code:

#!/usr/bin/bash
bininfotable=(20 20 20 20 20)
j=0
#find . -name "bin.txt" -type f -exec cat {} \; > nikhil.txt
while [ ${j} -le 5]
do
awk '/%/' /cygdrive/c/unix/bin.txt | awk '{print $3}'> $[collectbininfo[i]]
if [$[collectbininfo[j]] >= $[bininfotable[j]]] then
#$file_to_send = $[collectbininfo[i]]
echo "!! WAKE UP TIME TO ACT!!"
echo You have an error! Please see attached file
end if
j='expr $j +1'
done
-------------------------------

this gives me same error even after removing the carriage returns..

I would suggest you to convert the file formats from DOS to UNIX using any of the standard text editors(emacs).

How to Convert DOS and UNIX text files � Vasudeva Service

thanks it worked..