Created
May 3, 2018 10:52
-
-
Save davidcrx/09e98c06b0f7a7f06e64ffeb3804cdbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONTADOR=1 | |
let MINUMERO=$(( $RANDOM %6 + 1)) #Numero aleatori del 1 al 6 | |
echo ' '; echo 'Numero Aleatorio entre 1 y 6' | |
echo '***************************************************' | |
read -p "Digam el teu nom: " NOMBRE | |
echo '***************************************************' | |
echo ' ' ; echo ' ' | |
read -p "Portes $CONTADOR intents. Digam un número: " NUMERO | |
# | |
until [ $NUMERO -eq $MINUMERO ]; do | |
if [ $NUMERO -gt $MINUMERO ]; then | |
echo "Tu numero ingresado es menor" | |
else | |
echo "Tu numero ingresado es mayor" | |
fi | |
let CONTADOR=CONTADOR+1 | |
read -p "Portes $CONTADOR intents. Digam un numero: " NUMERO | |
done | |
# | |
echo "Bra-vo. Ho has encertat!." | |
#OPCIONAL, ESTADISTICA DE VALORS, MOLA :D | |
# grabem el record en el fitxer (primer els intents i després el nom) | |
echo $CONTADOR:$NOMBRE >> record.txt | |
# ordenem per deixar a dalt els que ho han fet en menys intents. | |
# I ens quedem amb les 5 primeres lineas | |
sort record.txt -n | head -5 > recordtemp.txt | |
cp recordtemp.txt record.txt | |
echo "Good Bye :)" | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment