Skip to main content
fixed if statement and optional "||" instead of pipe "|" - Actually this answer is already here: https://stackoverflow.com/a/16508612/2571881
Source Link
SergioAraujo
  • 12k
  • 3
  • 52
  • 45
read -r -p "Are you sure? [Y/n]" response  response=${response,,}  # tolower  if [[ $response =~ ^(yes|y| ) ]] # if|| only[[ press-z Enter$response we]]; needthen  detect this condiction your-action-here fi 
read -r -p "Are you sure? [Y/n]" response response=${response,,}  # tolower if [[ $response =~ ^(yes|y| ) ]] # if only press Enter we need detect this condiction 
read -r -p "Are you sure? [Y/n]" response  response=${response,,} # tolower  if [[ $response =~ ^(yes|y| ) ]] || [[ -z $response ]]; then   your-action-here fi 
Source Link
SergioAraujo
  • 12k
  • 3
  • 52
  • 45

read -r -p "Are you sure? [Y/n]" response response=${response,,} # tolower if [[ $response =~ ^(yes|y| ) ]] # if only press Enter we need detect this condiction