有没有办法让以下Bash脚本显示两个提示中的每一个 之前选择菜单而不是之后?
感谢。
#!/usr/bin/env bash
PS3='Copy database to which server? '
options=("debug" "dev" "prod" "Quit")
select server in "${options[@]}"
do
case $server in
"debug")
break
;;
"dev")
break
;;
"prod")
break
;;
"Quit")
echo "Quitting"
exit 1
;;
*) echo "Invalid option";;
esac
done
PS3='Reuse existing user data or get fresh data? '
options=("existing" "fresh" "Quit")
select data in "${options[@]}"
do
case $data in
"existing")
break
;;
"fresh")
break
;;
"Quit")
echo "Quitting"
exit 1
;;
*) echo "Invalid option";;
esac
done
echo "You chose "$server" and "$data
exit 1
答案 0 :(得分:0)
是......您可以随时使用echo
:
echo 'Copy database to which server?'
options=("debug" "dev" "prod" "Quit")
select server in "${options[@]}"
do
case $server in
"debug")
break
;;
"dev")
break
;;
"prod")
break
;;
"Quit")
echo "Quitting"
exit 1
;;
*) echo "Invalid option";;
esac
done
这会给你:
Copy database to which server?
1) debug
2) dev
3) prod
4) Quit
#?