Interactive Menus With select

Offer a numbered choice list without writing menu code.

macOSbashshellscriptingLow risk
Use select opt in a b c to present numbered options and read the choice into $opt.

01Command

Command
$ select opt in start stop status; do echo "chose: $opt"; break; done

02What it does

select prints a numbered menu, reads a choice and loops until you break, all built into the shell. It is handy for small admin scripts where a full TUI would be overkill, and it needs no external menu library.

03Risk

RiskLow risk
RequirementsmacOS default zsh/bash (bash 3.2+; some features need bash 4+ via Homebrew)
CompatibilitymacOS with bash 3.2+ (GNU bash 4+ via Homebrew for advanced features)
!Warning: select always reads from the terminal, so avoid it in non-interactive or piped scripts.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer