0

I have two services with a certain version which I need to compare for some processing:

Eg.

v1=1.5
v2=1.5.3

I want to compare them:

if [ $v1 -eq $v2 ]; then echo "equal" else echo "not equal"; fi

When I do the above, I get

bash: [: 1.5: integer expression expected

I tried surrounding the values and vars in double quotes but still the same error. I read about using 'bc' but not sure how to use it in the if condition, any help appreciated, thanks.

L P
  • 1,616
  • 5
  • 25
  • 44

0 Answers0