Shell脚本 - 查看系统信息
Shell脚本 - 查看系统信息
#!/bin/bash
#********************************************************************
#Author: lhl
#Date: 2025-09-03
#FileName: systeminfo.sh
#Description: systeminfo
#********************************************************************
set -ueRED="\E[1;31m"
GREEN="echo -e \E[1;32m"
END="\E[0m"
$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 '^vd' |tr -s ' ' |cut -d " " -f4`$END"
$GREEN---------------------------------------------------------$END
亲测有效