echo "Do you really want to continue (y/n)? \c" read answer_yes_no #------------------------------------------------------------------------------- # IF NOT OK, TERMINATE SCRIPT #------------------------------------------------------------------------------- if [[ ! $answer_yes_no = 'y' ]] then echo OK. Terminated. exit 1 fi _______________________________________________________________________________________________________ #------------------------------------------------------------------------------- # LOOP ANSWER #------------------------------------------------------------------------------- while [[ ! $answer_yes_no = 'y' ]] do echo "Do you really want to continue (y/n)? \c" read answer_yes_no done _______________________________________________________________________________________________________ #------------------------------------------------------------------------------- # CHECK ANSWER ONLY IN NON-SILENT-MODE #------------------------------------------------------------------------------- export s_parm=$1 if [[ $s_parm = '-s' ]] then export s_silent='y' else echo "This script will delete the files listed above. Do you really want to continue (y/n)? \c" read s_answer_yes_no #------------------------------------------------------------------------------- # IF NOT OK, TERMINATE SCRIPT #------------------------------------------------------------------------------- if [[ ! $s_answer_yes_no = 'y' ]] then echo terminated exit 1 fi fi echo proceeded _______________________________________________________________________________________________________ #------------------------------------------------------------------------------- # ANSWER WITH DEFAULT VALUE #------------------------------------------------------------------------------- answer_yes_no=y echo "Do you really want to continue (y/n)? \c" read answer_yes_no if [[ $answer_yes_no = '' ]] then answer_yes_no=y else if [[ ! $answer_yes_no = 'y' ]] then echo OK. Terminated. exit 1 fi fi echo answer is: $answer_yes_no exit 0