#!/bin/bash
#
#********************************************************************
#Author: QH
#QQ: 1625317303
#Date: 2019-03-16
#FileName: sysinfo.sh
#Mail: 1625317303@qq.com
#Description: The test script
#Copyright (C): 2019 All rights reserved
#********************************************************************
BEGINCOLOR="\e[1;35m"
ENDCOLOR="\e[0m"
echo -e "My hostname is ${BEGINCOLOR}`hostname`$ENDCOLOR"
echo -e "IP address is ${BEGINCOLOR}`ifconfig ens33 |grep -Eo ‘([0-9]{1,3}\.){3}[0-9]{1,3}‘|head -n1`$ENDCOLOR"
echo -e "OS version is ${BEGINCOLOR}`cat /etc/redhat-release`$ENDCOLOR"
echo -e "Kernel version is ${BEGINCOLOR}`uname -r`$ENDCOLOR"
echo -e "CPU type is ${BEGINCOLOR}`lscpu|grep "Model name" |cut -d: -f2 |tr -s " "`$ENDCOLOR"
echo -e "Memtotol is ${BEGINCOLOR}`cat /proc/meminfo |head -n1 |grep -Eo ‘[0-9]+.*‘`$ENDCOLOR"
echo -e "Disk space is ${BEGINCOLOR}`lsblk |grep ‘sda\>‘|grep -Eo ‘[0-9]+[[:upper:]]‘`$ENDCOLOR"
原文地址:https://blog.51cto.com/9019400/2364528