"Command not found" doing a while loop in bash/shell

i=0
numberofproducts=${#urls[@]}  #gets number of entries in array called "urls"
numberofproductsminusone=`expr $numberofproducts - 1`   #-subtract by one

while [$i -lt $numberofproducts]
do
	wget ${urls[$i]}
	 i=$(( $i + 1 ))
	sleep 10
done

I'm getting an error

./scrape: line 22: [0: command not found

that line corresponds with the "while" line.

Could anyone help me with this ? I googled but none of the examples I found were relevant to this.

Put a space in between the square brackets and variables:

while [ $i -lt $numberofproducts ]

Add a space between the [ and the $ on that line.

Regards,
Alister

---------- Post updated at 03:20 PM ---------- Previous update was at 03:18 PM ----------

Curse you, bipinajith!!! You beat me to the treasure yet again. I shall have my revenge!!! Just you wait. MWUAAHAHAHAHA. :wink:

Reminds me of Maximus Decimus Meridius in Gladiator... hahaha :smiley:

Understanding the results: Indexed URL

Important notes: