如果要执行所有案例,不应使用break。
还有在第三种情况下
/tmp/./test1.sh
./tmp/test1.sh
或
sh /tmp/test1.sh
你的代码应该是:
#!/bin/bash
# -----
# Menu:
# -----
while :
do
echo "Menu"
echo "1 - Change directory to /tmp"
echo "2 - Create file test1.sh in /tmp"
echo "3 - Execute test1.sh"
echo "4 - Execute R-script [/tmp/test2.R]"
echo "Exit - any kind but not [1-4]"
read answer;
case $answer in
1)
echo "Change directory to [\tmp]"
cd /tmp # Command to be executed.
pwd
;;
2)
echo "Create file [test1.sh] in [\tmp]"
touch /tmp/test1.sh # Command to be executed.
;;
3)
echo "Execute file [test1.sh]"
./tmp/test1.sh # Command to be executed.
;;
4)
echo "Execute R-script [/tmp/test2.R]"
/usr/bin/Rscript /production/20_front_trader/build/x_run_front_trader.R # Command to be executed.
;;
*)
# Command goes here
echo "Exit"
;;
esac
done