I have an dynamic number of options for a user prompt, and if possible would like manage the actions for each through a case statement.
Besides the dynamic number of options, the pattern will be build dynamically, and also the actions to do inside of each pattern. I understand that a loop has to be used inside the case statement, but I can't figure how to do this trick (even whether is possible)
An basic example of the idea:
totalitems=5
for ((c_a=1;c_a<=totalitems;c_a++))
do
echo "option $c_a"
done
read -n 1 -p "Choose an option from: 1 to $c_a" answer
case "$answer" in
#for ((c_a=1;c_a<=totalitems;c_a++))
#do
$c_a)
echo "$c_a"
;;
#done
*) echo "invalid option!"
sleep 1
exit;;
esac