[root@localhost ~]# cat uname.sh #!/bin/bash main=`uname -r | awk -F . '{print $1}'` minor=`uname -r | awk -F . '{print $2}'` if [ "$main" -eq 3 ] && [ "$minor" -ge 10 ] then echo "main version is :$main minor version is :$minor" else echo "main version is not 3" fi
[root@localhost ~]# uname -r 3.10.0-1062.el7.x86_64
[root@localhost ~]# sh uname.sh main version is :3 minor version is :10
脚本测试无误,可以使用