All,
I have 2 version lines, for example. "2.0.13" and "2.0.2". I need to compare 2 versions and determine which one is higher.
How to do this using bash?
You can use sort -V(version sorting):
sort -V
echo -e "2.0.13\n2.0.2" | sort -V
leads to:
2.0.2 2.0.13
From bmk
You can use sort -V (sort sort)
This is the best answer if it works, but unfortunately not all commands sorthave a parameter -V.
sort
-V
, Perl. Perl , "v". gt.
gt
. Perldoc perldata.
If you haven't -V, I'm sure there should be a way to do this by combining:
-t .
-n
-k
But I can’t make it work!