keyword

Bash select menu

Bash menu construct: numbers choices on stderr, reads stdin, assigns selected item or empty string for invalid nonempty input, stores raw line in REPLY. Ends at break or EOF; EOF returns status 1.

Formal Syntax & Structure

bash syntaxbash
select name [in words ...]; do commands; done

Return Value

exit status

Bash menu construct: numbers choices on stderr, reads stdin, assigns selected item or empty string for invalid nonempty input, stores raw line in REPLY. Ends at break or EOF; EOF returns status 1.

Working Example

Example Snippetbash
PS3='Choose: 'select choice in Start Quit; do  printf 'choice=%s reply=%s\n' "$choice" "$REPLY"  breakdone < <(printf '2\n')
Bash Reference