编写脚本 systeminfo.sh,显示当前主机系统信息,包括:主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小

#!/bin/bash

echo "MY hostname is `hostname`"
echo "My IPv4 address is `ifconfig | egrep -w "inet" | head -n1 | tr -s " " ":" | cut -d: -f4` "
echo "My Kernel is `cat /etc/redhat-release` "
echo "My CPU is `lscpu | egrep "Model name" | tr -s ' ' | cut -d: -f2`"
echo "My Mem is `free | egrep "Mem" | tr -s " " ":" | cut -d: -f2`"
echo "My Disk is `lsblk | egrep "^sda" | tr -s " " | cut -d" " -f4`"

posted @ 2022-03-16 10:41  海月如希  阅读(150)  评论(0)    收藏  举报