请选择 进入手机版 | 继续访问电脑版

悍铭论坛

 找回密码
 立即注册
查看: 585|回复: 0

sh脚本获取Linux系统名称

[复制链接]

31

主题

42

帖子

376

积分

LV3

Rank: 3Rank: 3

积分
376
发表于 2020-3-31 09:46:41 | 显示全部楼层 |阅读模式
代码:
  1.     #!/bin/bash
  2.     PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3.     export PATH
  4.     if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
  5.         OSNAME='CentOS'
  6.     elif grep -Eqi "Red Hat Enterprise Linux Server" /etc/issue || grep -Eq "Red Hat Enterprise Linux Server" /etc/*-release; then
  7.         OSNAME='RHEL'
  8.     elif grep -Eqi "Aliyun" /etc/issue || grep -Eq "Aliyun" /etc/*-release; then
  9.         OSNAME='Aliyun'
  10.     elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
  11.         OSNAME='Fedora'
  12.     elif grep -Eqi "Amazon Linux AMI" /etc/issue || grep -Eq "Amazon Linux AMI" /etc/*-release; then
  13.         OSNAME='Amazon'
  14.     elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
  15.         OSNAME='Debian'
  16.     elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
  17.         OSNAME='Ubuntu'
  18.     elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
  19.         OSNAME='Raspbian'
  20.     elif grep -Eqi "Deepin" /etc/issue || grep -Eq "Deepin" /etc/*-release; then
  21.         OSNAME='Deepin'
  22.     else
  23.         OSNAME='unknow'
  24.     fi

  25.     echo "$OSNAME"
复制代码




您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|悍铭论坛 ( 滇ICP备19004051号-1 )

GMT+8, 2020-12-6 01:36 , Processed in 0.040992 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表