加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

regex – 如何使用shell脚本查找Linux Distribution名称?

发布时间:2020-05-23 11:42:55 所属栏目:Linux 来源:互联网
导读:我正在编写一个shell脚本,其中我需要当前的操作系统名称以使其通用.喜欢:if [ $Operating_System == CentOS ] then echo CentOS; # Do this elif [ $Operating_System == Ubuntu ] then echo Ubuntu;

我正在编写一个shell脚本,其中我需要当前的操作系统名称以使其通用.喜欢:

if [ $Operating_System == "CentOS" ]
then
    echo "CentOS";
    # Do this
elif [ $Operating_System == "Ubuntu" ]
then
    echo "Ubuntu";
    # Do that
else
    echo "Unsupported Operating System";
fi

怎么可能?在lsb_release -a命令或其他地方应用正则表达式?

谢谢..

最佳答案
$lsb_release -i
Distributor ID: Fedora
$lsb_release -i | cut -f 2-
Fedora

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读