Case with list of pickes

I need help with following :-
I have the following function:-

 function queuecreate {

    echo "1 - Bread"
        echo "2 - Milk"
        echo "3 - Suger"
        echo "4 - Coffee"     

    echo "What do you need? > "
    read QT
    
    case $QT in
    1 ) echo "You Chose Bread"
        ;;
        2 ) echo "You Chose Milk"
        ;;
        3 ) echo "You Chose Suger"
        ;;
        4 ) echo "You Chose Coffee"
        ;;

        1 | 4 ) echo "You Chose Bread and Coffee"
        ;;
* ) echo "You did not enter a number"
        echo "between 1 and 4." 

esac

Currently the script will print whatever number I input , for example if I input 1 , the
output will be (You Chose Bread) and so on. and if I input 1 and 4 the output will be (You Chose Bread and Coffee)

How can I change it in the way look like this :-

What do you want ?

( ) Bread
( ) Milk 
( ) Suger 
( ) Coffee 

Type yes next to the Iteam you want.

So if the I type yes next to Bread and yes next to coffee

(yes) Bread
( ) Milk 
( ) Suger 
(yes) Coffee 

the output should be:

You chose Bread and Coffee

What OS and shell are you using?

You could use curses to do what you're suggesting, but it would be a lot easier to keep the numbered list you had before and allow the user to enter one or more values in the data you store in the variable QT . The way to efficiently process the returned value would vary depending on the shell you're using.

Don ,
I am using Linux and AIX,

I agree with you, keeping the number will be easy , however , my list has around 30 iteams , I am using the above example just to give me hint .

so my list qround 30 iteams , it will be hard to give case like

1 | 4 | 20 | 30 because I don't know what I might chose between 1 to 30.

I though maybe there is way to do it like 1-30 , or by writing yes next to it

---------- Post updated at 10:42 AM ---------- Previous update was at 03:40 AM ----------

:frowning: Any Ideas are welcome

You could experiment with dialog :

dialog --checklist "Choose item(s):" 11 35 5 \
    1 Bread off \
    2 Milk off \
    3 Sugar off \
    4 Coffee off \
2>/tmp/answer.$$

The following is easy to extend

  items="\
1 - Bread
2 - Milk
3 - Suger
4 - Coffee"     
  echo "$items"
  echo "What do you need? > "
  read QT
  choice=`echo "$QT" | tr -sc '[:digit:] ' '\n'`
  picklist=""
  for ch in $choice
  do
    out=`
      echo "$items" |
      while read i1 dash i2
      do
        if [ $ch = $i1 ]; then
          echo $i2
        fi
      done
    `
    if [ -z "$out" ]; then
      echo "$ch is out of range"
    else
      picklist="$picklist $out"
    fi
  done
  echo "You chose $picklist"

Here is another way to do this just using standard interfaces:

queuecreate() {
	echo "1  - Bread"
	echo "10 - Milk"
	echo "11 - Suger"
	echo "14 - Coffee"     
	printf 'What do you need? (Enter space separated list of codes): '
	read QT
	set -- $QT

	for choice in "$@"
	do	case $choice in
		(1)	echo "You Chose Bread";;
		(10)	echo "You Chose Milk";;
		(11)	echo "You Chose Suger";;
		(14)	echo "You Chose Coffee";;
		(*)	printf 'Code "%s" is not valid\n' "$choice";;
		esac
	done
}
while [ 1 ]
do	queuecreate
	printf 'Try again? (y or n): '
	read resp
	case $resp in
	(N*|n*)	exit 0
	esac
done

Note that I used 1, 10, 11, and 14 just to get the resulting values into double digits without needing to enter 10 choices. If you want to print a more English like list with commas and an "and" where appropriate, you can easily complicate the logic in the case statement a little bit to make that happen.

Does this help?

What's a pickes?

Thread title: Case with list of pickes

My guess is pickies

I thought it was just a typo for "picks" (as in "selections").

Both codes which MadeInGermany and Don Cragun provided are exactly what I wanted . I really appreciated your time and helps.
Also , thank you junior-helper for your time as well, but we are trying to avoid use dialog,

Yes I meant selections, sorry for the confusing

Thank you all

:b::b::b::b::b::b::b::b::b::b::b::b::b::b::b: