写一个shell脚本,实现简单的弹出式菜单功能,用户能根据显示的菜单项从键盘选择执行对应的命令。
#!/bin/bash
PS3="Please input your choice(1-4): "
select i in w ls pwd quit
do
case $i in
w)
w
;;
ls)
ls
;;
pwd)
pwd
;;
quit)
exit
;;
*)
echo "Please input 1-3."
;;
esac
done
#!/bin/bash
echo -e "1) w\n2) ls\n3) pwd\n4) quit"
while :
do
read -p "Please input your choice(1-4): " c
case $c in
1)
w
;;
2)
ls
;;
3)
pwd
;;
4)
exit
;;
*)
echo "Please input 1-4."
;;
esac
done