bash: choose default from case when enter is pressed in a “select” prompt
I'm prompting questions in a bash script like this: optionsAudits=("Yep" "Nope") echo "Include audits?" select opt in "${optionsAudits[@]}"; do case $REPLY in 1) includeAudits=true; break ;; 2) includeAudits=false; break ;; "\n") echo "You pressed enter"; break ;; # <--- doesn't work *) echo "What's that?"; exit;; esac done How can I select a default option when enter is pressed? The "\n" case does not catch the enter key. mklement0 To complement Aserre's helpful answer , which explains the problem with your code and offers an effective workaround, with background information and a generic,