Compair Version Numbers in Bash

[david@Galileo ~]# function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
[david@Galileo ~]# ver1=10.1.2.9
[david@Galileo ~]# ver2=10.01.02.008
[david@Galileo ~]# if [ $(version $ver1) -gt $(version $ver2) ]; then echo "$ver1 is newer $ver2"; else echo "$ver1 is NOT newer $ver2"; fi
10.1.2.9 is newer 10.01.02.008