We have to make a script with one until
loop to repeatedly ask
the user for a number.
- If the number is not 50, display the message, “Wrong number; try again.”
- ask for another number.
- If the number is 50, display the message, “You got it!” and stop.
Here is what I have so far:
echo -n "please choose a number: "
read number
until [$number -eq 50];
do
if [$number !=50]
then
echo "Wrong number; try again"
read wrong
else
echo -n "Please choose a number: "
read newnum
fi
done
I'm not sure how to loop the "Please choose a number" statement. I always end up with the error:
syntax error near unexpected token 'fi'
I've been looking online, but there are no clear examples of input output UNTIL loops
[ ... ]
constructs, you wrotenumber
to get the value of the variable instead of$number
, you use a different variable name laternewnum
instead ofnumber
, you don't put double quotes around tests like so:"$number"
. You need to follow a shell scripting tutorial