version_compare() { source=(${1//./ }) target=(${2//./ }) for ((i=0; i<${#source[@]}; i++)); do if [[ ${source[i]} == ${target[i]} ]]; then continue fi if [[ ${source[i]} -lt ${target[i]} ]]; then echo -1 return elif [[ ${source[i]} -gt ${target[i]} ]]; then echo 1 return fi done echo 0 } getSystemVersion() { releasetmp=`cat /etc/redhat-release | awk -Frelease '{print $2}' | awk -F. '{print $1}' | awk '{print $1}'` echo $releasetmp }