编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小
#! /bin/bash
echo -e 主机名 : `hostname`
echo -e IPv4地址 :`ifconfig | sed -n 2p |tr -s | cut -d -f 3`
echo -e 操作系统版本 : `cat /etc/redhat-release`
echo -e 内核版本: `uname -r`
echo -e CPU型号: `lscpu|sed -n 13p | tr -s |cut -d -f2-`
echo -e 内存大小 : `cat /proc/meminfo | grep MemTotal`
echo -e 硬盘大小: `lsblk | grep -E '^sda' | grep -Eo [0-9]+[[:upper:]]`
