In Bash, how to add “Are you sure [Y/n]” to any command or alias?
These are more compact and versatile forms of Hamish’s answer. They handle any mixture of upper and lower case letters: read -r -p “Are you sure? [y/N] ” response case “$response” in [yY][eE][sS]|[yY]) do_something ;; *) do_something_else ;; esac Or, for Bash >= version 3.2: read -r -p “Are you sure? [y/N] ” response if … Read more