实例:脚本实现
[root@CentOS7 shellscript]# vim systeminfo.sh
#!/bin/bash
#
#**********************************
# Author: wanghongrong
# Date: 2021-05-10
# FileName: systeminfo.sh
# Url: http://www.werida.com
# Copyright(C):2021All rights reserved
#**********************************
echo "OS: $(uname)"
echo "OS ver: $(cat /etc/redhat-release | cut -d ‘ ‘ -f 2,4)"
echo "HOSTNAME: $(hostname)"
echo "ipv4 addr: $(ip a | grep global | cut -d ‘ ‘ -f 6)"
echo "kernel ver: $(uname -a | cut -d ‘ ‘ -f 3)"
echo "CPU model: $(cat /proc/cpuinfo | grep name | cut -f2 -d :|uniq)"
echo "mem size: $(free -mh | grep Mem | cut -f12 -d ‘ ‘)"
echo "disk size: $(df -h | grep ^/.* | cut -d ‘ ‘ -f1,8)"
[root@CentOS7 shellscript]# sh systeminfo.sh
OS: Linux
OS ver: Linux 7.2.1511
HOSTNAME: CentOS7.localdomain
ipv4 addr: 10.0.0.7/8
172.17.0.1/16
kernel ver: 3.10.0-327.el7.x86_64
CPU model: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz
mem size: 1.8G
disk size: /dev/sda2
/dev/sda5 142G
/dev/sda1 997M
原文:https://www.cnblogs.com/hony625/p/14751585.html