I am not sure which policy here asks questions about the next steps. So please excuse me if I break the protocol. I used to build a menu in bash ( here )
And so far it worked very well for me. The code is here.
while [[ 1 ]]
do
cat -n "$dumpfile"
read -p "Please make a selection, select q to quit: " choice
case $choice in
[0-9] ) dtvariable=$(sed -n "$choice"p "$dumpfile")
$dtvariable ;;
q|Q)
break
;;
*)
echo "Invalid choice"
;;
esac
done
In addition, this works great for menu items up to 9. The menu will be dynamic - it can have 1 item, 20 items, or 197 items. I tried changing [0-9] to [0-9] [0-9] to see if it would be 12. But it is not. Can someone put me on the right track? I suppose I could just delete part [0-9] and take everything that is not q. But isnβt it better to look for numbers?
Thanks in advance.