編寫腳本 systeminfo.sh,顯示當前主機系統信息,包括主機名,IPv4地址, 操作系統版本
阿新 • • 發佈:2019-03-18
script 腳本 圖片 ext lsblk 分享 .com 操作 clas
#!/bin/bash
#
#********************************************************************
#Author: QH
#QQ: 1625317303
#Date: 2019-03-16
#FileName: sysinfo.sh
#Mail: [email protected]
#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"
編寫腳本 systeminfo.sh,顯示當前主機系統信息,包括主機名,IPv4地址, 操作系統版本