well.... that tells me that your curl ... | grep ... | cut ... is not returning what you think it's returning.
You need to debug how the htcount is derived.
Oh no, hang on - this doesn't make much sense... the echo "[${htcount}]" is supposed to return the value inside , but it isn't.
The issue is somewhere else.
Add set -x at the top of your script and see what comes out.
And change echo "[${htcount}]" to echo "htcount->[${htcount}]"
No. What you're seeing is evidence that the output from the curl command is using DOS <carriage-return><newline> line terminators instead of UNIX <newline> line terminators. The echo output is showing that htcount has been set to " 1<cr> " (where <cr> is a carriage return character). Since <cr> is not a numeric character, the test utility is complaining that "${htcount}" expands to a non-numeric string that is not valid in an operand of the binary -ge test operator. Note that an easier way to see this is to use: