bash scripting: how to get item name on a radiolist using dialog
i need to make a radiolist in bash script using dialog interface, for example if i have the following list:
dialog --backtitle "OS infomration" 
--radiolist "Select OS:" 10 40 3 
 1 "Linux 7.2" off 
 2 "Solaris 9" on 
 3 "HPUX 11i" off
I want that when the user choose an option and press ok my scripts read the item name (and not the item number).
It is possible? Thanks!
你可以把你的预期结果放在一个数组中:
array=(Linux Solaris HPUX)
var=$(dialog --backtitle "OS infomration" 
--radiolist "Select OS:" 10 40 3 
 1 "Linux 7.2" off 
 2 "Solaris 9" on 
 3 "HPUX 11i" off >/dev/tty 2>&1 )
printf 'nnYou chose: %sn' "${array[var - 1]}"
