How to prompt user confirmation using Bash

I found a nice tips to create a prompt for user confirmation using Bash. Its pretty simple and neat. Here is the example to create a user confirmation (y/n) on Bash:

[codesyntax lang=”bash” lines=”normal” lines_start=”0″]


When user press y or Y, it will return “yes”. If user press n or N, it will return no. Otherwise it will return “invalid”. Its pretty easy.



Leave a Reply

Your email address will not be published. Required fields are marked *