linux中国网

菜菜鸟的linux杂记

shell判断系统为centos7

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

还有其它办法 在这里就不一一而言

评论已关闭。