Files
Bash/UntilDoDone.sh
T
2026-10-09 08:01:19 +02:00

27 lines
586 B
Bash

# Boucles sur saisies : nombre à trouver
a_trouver=$((($RANDOM%10)+1))
Essais=3
# echo "$a_trouver"
echo -e "Saisir un nombre entre 1 et 10 : \c"
read Nombre
until [ "$Nombre" -eq "$a_trouver" ]
do
if [ "$Nombre" -lt "$a_trouver" ]
then
echo "trop petit !"
else
echo "trop GRAND !"
fi
Essais=`expr $Essais - 1`
if [ $Essais -eq 0 ]
then
echo "PERDU ! Le nombre a trouver etait : $a_trouver :("
exit 1
fi
echo "Il vous reste $Essais essais.."
echo -e "Saisir un nombre entre 1 et 10 : \c"
read Nombre
done
echo "BRAVO !"
exit 0