BASH, How do you repeat a command if a user response is No? -
here talking how script jump first echo statement if no selected, thanks?
echo "please enter input: " read input_variable echo "you entered: $input_variable" read -r -p "is correct? [y/n] " response case $response in [yy][ee][ss]|[yy] do_something ;; *)
{return first line - echo "please enter input: "}
;; esac
wrap prompts in while
loop break
out of once input confirmed:
while :; # same as: `while true; do` - keep looping until exited `break` echo "please enter input: " read -r input_variable echo "you entered: $input_variable" read -r -p "is correct? [y/n] " response case $response in [yy][ee][ss]|[yy]) break ;; esac done do_something
note not n
, input other matched case
handler cause loop remain active.
Comments
Post a Comment