Error in while loop

Hi,

Iam trying to add a while loop in my script in the below way which gets value from count file and checks if its not equal to 0.If yes then it shld echo me a message.

while["$cat count"!="0"] //count file has some number other than 0
do
echo "count is not zero"
done

But iam getting this error:
./test.sh: line 9: while[ count!=0]: command not found
./test.sh: line 10: syntax error near unexpected token `do'
./test.sh: line 10: `do'

can someone tell me wats the mistake.

you need spaces betweenthebrackets, and all will be well.

I don't think so, should be something like:

if [ $(cat count) != "0" ]
then
  echo "count is not zero"
fi

Assuming you have one number in your file.

Thanks.That worked.

Or the slightly simpler:

if [ "$(<count)" != 0 ]
then
  echo "count is not zero"
fi

sorry was on my mobile.