I have a case statement inside some of the if statement, but after doing the case statement inside the if statement, the loop ends. After the case statement, it is supposed to go to the next value on the array. What's happening is the first value in the array, after passing through the if-statement then case, the script finishes instead of looping to the other values in the array.
set -A arrs a b c d
num=`expr ${#arrs[*]} - 1`
for x in `seq 0 $num`
do
var1=`some command here`
var2=`some command here`
var3=`some command here`
if [[ "$var1" == "$var2" && "$var3" == "0" ]]; then
#do something here
elif [[ "$var1" == "$var2" && "$var3" != "0" ]]; then
echo "\nContinue?"
echo "[y/n]:\c"
read yes_no
case $yes_no in
[yY])
echo "You answer yes."
echo "Some text that will go to the text file" >> some_text.txt
break
;;
[nN])
echo "you answered no"
exit
;;
*)
echo "\nTry again"
;;
esac
elif [[ "$var1" != "$var2" && "$var3" == "0" ]]; then
echo "\nContinue?"
echo "[y/n]:\c"
read no_yes
case $no_yes in
[yY])
echo "You answer yes"
echo "Some text that will go to the text file" >> some_text.txt
break
;;
[nN])
echo "you answered no"
exit
;;
*)
echo "\nTry again"
;;
esac
else
echo "Do back flip"
exit
fi
done
Aucun commentaire:
Enregistrer un commentaire