菜单
#!/bin/bash
clear
echo "-------------------------------------------"
echo -e "\033[32m1.EtherNet information\033[0m"
echo -e "\e[33m2.Memrry information\e[0m"
echo -e "\e[34m3.Disk information\e[0m"
echo -e "\e[35m4.CPU information\e[0m"
echo -e "\e[36m5.User information\e[0m"
echo "-------------------------------------------"
echo
read -p "please choice [1-5]:" key
case $key in
1)
ifconfig eth0 |awk 'NR==2{print $2}'
;;
2)
free -h|awk 'NR==2{print $4}'
;;
3)
df -h |grep "/dev.vd"|awk '{print $5}'
;;
4)
cat /proc/cpuinfo |grep "model name"|head -1
;;
5)
who
;;
*)
echo "Error"
esac
------------------------------------------------------------20210816---------------------------------------------------------------
#!/bin/bash
echo "1.choice one"
echo "2.choice two"
echo "3.choice three"
echo "4.choice four"
echo "5.choice five"
while :
do
read -p "please input 1-6: " key
case $key in
1)
ifconfig eth0 |awk 'NR==2{print $2}'
;;
2)
free -h|awk 'NR==2{print $4}'
;;
3)
df -h |awk '/\/$/{print $4}'
;;
4)
lscpu |awk '/^Model name/'
;;
5)
hostname
;;
6)
exit
esac
done
#!/bin/bash
while : ; do
read -p "1.hostname 2.hostIP 3.memInfo 4.diskInfo 5.cpuInfo 6.exit;please choice 1-6: " key
case $key in
1)
echo "Your HostName is: `hostname`"
;;
2)
echo "Your HostIP is: `ifconfig eth0|awk 'NR==2{print $2}'`"
;;
3)
echo "free mem is: `free -h |awk 'NR==2{print $4}'`"
;;
4)
echo "free disk is: `df -h|grep /dev/vda|awk '{print $4}'`"
;;
5)
echo "cpu info is: `lscpu|sed -nr 's/(.* )(Intel.*)/\2/p'`"
;;
6)
exit
esac
done
~