cat /etc/redhat-release | cut -d . -f 1 | grep 7
myre=$?
if [ $myre -eq 0 ]
then
echo is 7
else
echo is 6
fi
cat /etc/redhat-release |grep 7\..*|grep -i centos>/dev/null
[ ! $? -eq 0 ] && echo "Please make sure your system is CentOS 7"&& exit
cut awk
还有其它办法 在这里就不一一而言