码迷,mamicode.com
首页 > 系统相关 > 详细

判断centos系统版本的shell

时间:2018-02-07 21:19:03      阅读:2087      评论:0      收藏:0      [点我收藏+]

标签:span   centos   12px   family   ror   tool   rgb   false   font   

日常维护中,需要写个通用的执行shell,但是centos 6 版本与 7版本的诸多命令不同,需要程序自己判断,方法如下:


 1、查看cat /etc/centos-release


root@pts/0 # cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'
7
root@pts/15 # cat /etc/redhat-release|sed -r 's/.* ([0-9]+)\..*/\1/'
6


2、查看rpm -q centos-release


root@pts/0 # rpm -q centos-release|cut -d- -f3
7
root@pts/15 # rpm -q centos-release|cut -d- -f3
6


判断centos系统版本的shell

标签:span   centos   12px   family   ror   tool   rgb   false   font   

原文地址:http://blog.51cto.com/chaichuan/2069965

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!