Linux显示系统信息sh脚本

Posted 白_胖_子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux显示系统信息sh脚本相关的知识,希望对你有一定的参考价值。

#!/bin/bash
#
#********************************************************************
#Author:                wangxiaochun
#QQ:                    29308620
#Date:                  2020-04-01
#FileName:             system_info.sh
#URL:                   http://www.magedu.com
#Description:          The test script
#Copyright (C):         2020 All rights reserved
#********************************************************************
RED="E[1;31m"
GREEN="E[1;32m"
END="E[0m"
echo -e "$GREEN----------------------Host systeminfo--------------------$END"
echo -e  "HOSTNAME:     $RED`hostname`$END"
echo -e  "IPADDR:       $RED` ifconfig eth0|grep -Eo ‘([0-9]{1,3}.){3}[0-9]{1,3}‘ |head -n1`$END"
echo -e  "OSVERSION:    $RED`cat /etc/redhat-release`$END"
echo -e  "KERNEL:       $RED`uname -r`$END"
echo -e  "CPU:         $RED`lscpu|grep ‘Model name‘|tr -s ‘ ‘|cut -d : -f2`$END"
echo -e  "MEMORY:       $RED`free -h|grep Mem|tr -s ‘ ‘ : |cut -d : -f2`$END"
echo -e  "DISK:         $RED`lsblk |grep ‘^sd‘ |tr -s ‘ ‘ |cut -d " " -f4`$END"
echo -e "$GREEN---------------------------------------------------------$END"
#!/bin/bash
#
#********************************************************************
#Author:                wangxiaochun
#QQ:                    29308620
#Date:                  2020-04-01
#FileName:             system_info.sh
#URL:                   http://www.magedu.com
#Description:          The test script
#Copyright (C):         2020 All rights reserved
#********************************************************************
RED="E[1;31m"
GREEN="E[1;32m"
END="E[0m"
echo -e "$GREEN----------------------Host systeminfo--------------------$END"
echo -e  "HOSTNAME:     $RED`hostname`$END"
echo -e  "IPADDR:       $RED` ifconfig eth0|grep -Eo ‘([0-9]{1,3}.){3}[0-9]{1,3}‘ |head -n1`$END"
echo -e  "OSVERSION:    $RED`cat /etc/redhat-release`$END"
echo -e  "KERNEL:       $RED`uname -r`$END"
echo -e  "CPU:         $RED`lscpu|grep ‘Model name‘|tr -s ‘ ‘|cut -d : -f2`$END"
echo -e  "MEMORY:       $RED`free -h|grep Mem|tr -s ‘ ‘ : |cut -d : -f2`$END"
echo -e  "DISK:         $RED`lsblk |grep ‘^sd‘ |tr -s ‘ ‘ |cut -d " " -f4`$END"
echo -e "$GREEN---------------------------------------------------------$END"

以上是关于Linux显示系统信息sh脚本的主要内容,如果未能解决你的问题,请参考以下文章

sh Linux服务器信息脚本

sh Linux服务器信息脚本

Linux系统shell脚本之打印系统的IP信息

linux sh脚本异常:/bin/sh^M:bad interpreter: No such file or directory

Linux显示系统信息的shell小脚本

sh 此脚本在大多数Linux系统上从源代码下载并安装fish shell。