我有一个基本菜单,可以完成已经设置给我的任务,我有要显示的菜单和要运行的功能,但是,当用户选择选项4时,结果只会在终端中闪烁分秒,如果他们选择了不正确的值,错误信息会闪烁,我需要他们两个保持不变。有什么想法吗?
#!/bin/bash
#
# Script to perform some simple tasks
#
chmod 755 TaskB.sh
while:
do
clear
echo "*********************"
echo "* Tools *"
echo "*********************"
echo "* [1] Install gnome-disk-utility and gparted *"
echo "* [2] Create CET103Demo.txt *"
echo "* [3] Delete CET103Demo.txt *"
echo "* [4] Search BASH *"
echo "* [0] Exit/Stop *"
echo "*********************"
echo -n "Enter your menu choice [0-4]: "
read yourch
case $yourch in
1) sudo apt-get install gparted gnome-disk-utility ;;
2) cat > Desktop/CET103Demo.txt;;
3) rm Desktop/CET103Demo.txt;;
4) grep -H -r "BASH" /home/mintuser/.profile ;;
0) exit 0;;
*) echo "Oooops!!! Please select choice 1,2,3,4 or 0";
echo "Press Enter to continue..."; read ;;
esac
done
答案 0 :(得分:0)
我暂时没有使用过bash,但试试这个:
#!/bin/bash
#
# Script to perform some simple tasks
#
chmod 755 TaskB.sh
while:
do
clear
echo "*********************"
echo "* Tools *"
echo "*********************"
echo "* [1] Install gnome-disk-utility and gparted *"
echo "* [2] Create CET103Demo.txt *"
echo "* [3] Delete CET103Demo.txt *"
echo "* [4] Search BASH *"
echo "* [0] Exit/Stop *"
echo "*********************"
echo -n "Enter your menu choice [0-4]: "
read yourch
case $yourch in
1) sudo apt-get install gparted gnome-disk-utility ;;
2) cat > Desktop/CET103Demo.txt;;
3) rm Desktop/CET103Demo.txt;;
4) grep -H -r "BASH" /home/mintuser/.profile ;;
0) exit 0;;
*) echo "Oooops!!! Please select choice 1,2,3,4 or 0" ;;
esac
read -p "Press [Enter] to continue..."
done
read -p "Press [Enter] to exit..."