0

I have a Bash script which compare Versionnumbers. But I need to compare even with a letter in it.

ver_a="1.0.0d4"
ver_b="1.0.0d5"

if [[ "$ver_a" -lt "$ver_b" ]]; then
  echo "New Version available!"
fi

This sample surely not works. Whats the correct way to process these letter?

Sascha7777
  • 89
  • 8
  • 1
    It works if you change `-lt` to `>` – oguz ismail May 27 '20 at 07:02
  • 1
    Possible duplicate of [How to compare two strings in dot separated version format in Bash?](https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash) – oguz ismail May 27 '20 at 07:05
  • 1
    @oguzismail ... at least if all numbers are single digits or padded to the same width. Otherwise you get `1.9 > 1.10`. For cases like that you can use `sort -V`. – Socowi May 27 '20 at 07:10
  • @Socowi right, a solution using sort -V is available in the linked duplicate – oguz ismail May 27 '20 at 07:15

0 Answers0