打印菜单脚本

#!/bin/bash
#
cat << EOF
cpu) show cpu information;
mem) show memory information;
disk) show disk information;
quit) quit
#############################################################
EOF

read -p "Enter a option:" option
while [ "$option" != 'cpu' -a "$option" != 'mem' -a "$option" != 'disk' -a "option" != 'quit' ];do
  read -p "Wrong option,please Enter again:" option
done

if [ "$option" == 'cpu' ];then
  lscpu
elif [ "$option" == 'mem' ];then
  cat /proc/meminfo
elif [ "$option" == 'disk' ];then
  fdisk -l
else
  echo "Quit"
  exit 0
fi
~      

  

posted @ 2017-10-12 15:40  BigZero  阅读(232)  评论(0编辑  收藏  举报