Bash Select
Contents
Select Menus
A select menu looks like:
1) /bin 3) /dev 5) /home 7) /lib64 9) /mnt 11) /proc 13) /run 15) /srv 17) /tmp 19) /var 2) /boot 4) /etc 6) /lib 8) /lost+found 10) /opt 12) /root 14) /sbin 16) /sys 18) /usr #?
Note that #? as shown above is the default $PS3 value.
This menu is printed to STDERR and waits for the user to make a selection from that menu.
Usage
The above menu was generated with:
select name in /*; do break done
The expansion is handled in the same manner as for loops. That includes the implcit default of iterating over $@.
The user selection is made available as $name in the above example. The 'loop' needs to be explicitly broken.