0

I've tried many version of this but none of them work.I want to compare variable - here it'll be version of os, with some string. I want to check if it is bigger than indicated version. When I pass exact name it is just fine, but when I want to replace something with .* it doesn't work.

if [[ "$(uname -r)" == '3\.18.*' ]];

then echo bravo;

fi

how to make it work? thanks in advance

  • Read the manual on the [`[[`](http://www.gnu.org/software/bash/manual/bash.html#index-_005b_005b) operator. You need the trailing `.*` outside of quotes, I think. – Jonathan Leffler Apr 15 '15 at 00:00

1 Answers1

2

I would use a case statement here:

case $(uname -r) in
(3.18.*) echo bravo;;
esac

If you want to check if the version is larger than some value or not, you might use something like:

case $(uname -r) in
(3.1[89].*|3.[2-9]*|[4-9]*) echo bravo;;
(*) echo alpha;;
esac
jlliagre
  • 29,783
  • 6
  • 61
  • 72