
Intenté usar "mientras" y "preguntar" sin éxito, pero el objetivo de este script es ejecutar uno o varios comandos y luego preguntar si desea repetir el comando nuevamente.
Ejemplo:
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
Respuesta1
Puede que haya una forma más sencilla, pero al menos ésta 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