
Tentei usar "while" e "ask" sem sucesso, mas o objetivo deste script é executar um comando ou comandos e perguntar se deseja repetir o comando novamente.
Exemplo:
echo "adding a whatever... stand by..."
# prompt for yes or no to repeat the above command. If no go to the next command.
echo "Done adding."
exit 0
Responder1
Pode haver uma maneira mais fácil, mas pelo menos funcionará.
#!/bin/bash
_repeat="Y"
while [ $_repeat = "Y" ]
do
# Do whatever your tasks are
# Prompt for repeat
echo -n "Repeat? (Y/N)"
read -n1 Input
echo # Completes the line
case $Input in
[Nn]):
_repeat="N"
;;
esac
done