0
我在腳本中使用以下代碼。Bash - 具有多個選項的閱讀案例
#!/bin/bash
while true; do
read -p "Do your Choice: [1] [2] [3] [4] [E]xit: " choice
case "$choice" in
[1]*) echo -e "$choice\n"; break;;
[2]*) echo -e "$choice\n"; break;;
[3]*) echo -e "$choice\n"; break;;
[4]*) echo -e "$choice\n"; break;;
[Ee]*) echo "exited by user"; exit;;
*) echo "Are you kidding me???";;
esac
done
我的問題是,我怎麼能拿到劇本接受多個選擇。 所以輸入像:1,4,
將運行案例[1]
和[4]
?
我想OP的代碼使用'break'從'while'循環中退出。 – Jdamian
好點,我會解決這個問題。 – yinnonsanders