
「while」と「ask」の使用を試みましたが成功しませんでした。このスクリプトの全体的な目的は、1つまたは複数のコマンドを実行し、コマンドをもう一度繰り返すかどうかを尋ねることです。
例:
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
答え1
もっと簡単な方法があるかもしれませんが、少なくともこれでうまくいくでしょう。
#!/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