-2

I wrote a batch file which checks for a particular count in if condition on the basis of which it executes the if and else code.It was working perfectly fine since 6 months.

But today it was executing the else condition instead of if condition

COUNT = 12
if [[ $COUNT > 10 ]]
then
echo "love"
else
echo "hate"
fi 

This is the kind of logic in my code is. So since last 6 months it was executing love.But today it executed hate.

What can be the reason?

marked as duplicate by muru, Prvt_Yadav, Kusalananda shell-script Sep 9 at 17:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • You haven't mentioned what shell your "batch file" uses, but at least for bash, the < and > operators sort lexicographically when used with [[ - I don't know if that's significant in your case (we'd need to see the actual code - not "the kind of logic") – steeldriver Sep 9 at 16:26
  • The first line is wrong: COUNT = 12 does not set COUNT to the value 12. Please double-check what you've typed, and fix any typos. – roaima Sep 9 at 16:29
  • COUNT=12 without spaces ;) – LinuxSecurityFreak Sep 9 at 16:31
  • @LinuxSecurityFreak we don't know that's what's in the script, despite it being obvious to us. – roaima Sep 9 at 16:31
  • that I agree it should be COUNT=10,But I wrote only to know you the value of COUNT. – Vivek Singh Sep 10 at 3:37

Browse other questions tagged or ask your own question.