2021-08-12-shell脚本-菜单

28 篇文章 0 订阅
27 篇文章 0 订阅

菜单

#!/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
~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值