Command Format: select identifier [in list]
do
commands
done
In the select command:
ksh will display the items in one or more columns on standard
error, each preceded by a number. The PS3 prompt follows. The
number of columns is determined by the values of COLUMNS and LINES.
ksh will then read a selection line from standard input. If the
line is the number of one of the displayed items, ksh sets the
value of "identifier" to the item corresponding to this number. If
the line is empty, ksh again displays the list of items; and the
prompt is redisplayed. The "commands" are not executed.
ksh saves the contents of the selection line read from standard
input in the KornShell variable REPLY.
ksh runs "commands" for each selection until ksh encounters a
break, return, or exit command in the "commands" list.
Sample Session:
$cat select.ksh
stty erase
select myselection in fred wilma pebbles barney betty
do
case $myselection in
fred)
echo Fred was the selection
;;
wilma)
echo Wilma was the selection
;;
pebbles)
echo Pebbles was the selection
;;
barney)
echo Barney was the selection
;;
betty)
echo Betty was the selection
;;
esac
done
$chmod 755 select.ksh
$select.ksh
1) fred
2) wilma
3) pebbles
4) barney
5) betty
#? 3
Pebbles was the selection
#? 5
Betty was the selection
#? 6
#? 4
Barney was the selection
# Ctrl-C
$