Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Not accepting default Y Commented Feb 20, 2015 at 14:43
  • 1
    For default Y if [[ $response =~ ^(yes|y| ) ]] | [ -z $response ]; then Commented Feb 20, 2015 at 14:48
  • 2
    In the regex, there is no need to match both yes and y, just y beginning is enough. Also, if default needs to be no, then the following would be helpful. read "response?Are you sure ? [Y/n] " && if [[ "$response" =~ ^[Yy] ]]; then echo "Yes, you did it."; else echo "No, narrow escape"; fi Commented Jun 28, 2018 at 20:42