From cca70e95c250c28737bd7be83efc78ff8a7886af Mon Sep 17 00:00:00 2001 From: gitea Date: Fri, 9 Oct 2026 08:01:19 +0200 Subject: [PATCH] Add UntilDoDone.sh --- UntilDoDone.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 UntilDoDone.sh diff --git a/UntilDoDone.sh b/UntilDoDone.sh new file mode 100644 index 0000000..a37d086 --- /dev/null +++ b/UntilDoDone.sh @@ -0,0 +1,26 @@ +# 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