I have been trying to write a script that will ask the user whether he/she should run the command again.
If the answer is yes, then it should execute the last command again. Even after 2nd time execution, it should ask the user whether should it run the last command or not. I want this to be happen until the answer becomes no, if the answer is no then it should exit.
$ cat shellscript.sh echo foo printf 'Can I run the last command (y/n)?'
If my answer is yes, then it should run the command "echo foo"
# after the 1st time execution printf 'Can I run the last command again (y/n)?'
It will run the command again if the answer is yes, it will do the same (asking y/n and the execution) until the answer is yes. if no, then it should exit.
I think I need to implement some sort of loop, but I got confused as this is conditional script.