I have this script,
#!/bin/sh
guess=$(echo $RANDOM | cut -b 1-2)
read -p "Im thinking of a number, can you guess what it is? " number
case "$number" in
"$guess") echo "\nCongratulation number guessed corectly!"
exit 0
;;
) echo "\nIncorrect number guessed, try again? [yes or no]"
read yesorno
case "$yesorno" in
"yes") sh guess.sh
;;
"no") echo "\nHave a nice day!"
exit 0
;;
) echo "Invalid input"
exit 1
;;
esac
;;
esac
The variable $guess was suppossed to return a 2 digit number, but returns null. Running the game with sh guess.sh
and pressing return, returns congrats instead of the correct number being guessed. Where am I going wrong
sh
!=bash
. – muru Dec 29 '20 at 19:37