I'm making a bash script that asks the user for a number between 10 and 100 then gives echos that state whether the number was to low or to high.
Please excuse the code, I'm very new to bash scripting and still learning, I'm sure I have quite a bit of the basic Syntax errors.
Here is the code.
#!/bin/sh
echo "Enter a Number between 10 and 100."
read num
if ["$num" -gt 10 -a "$num" -lt 100] ; then
echo "The Number `$num` is just right"
elif ["$num" -lt 10] ; then
echo "Number to small"
elif ["$num" -gt 100] ; then
echo "Number to big"
else
echo "Enter In a Number between 10 and 100"
fi
And Here is the error message that I have been getting.
$ ./Num*
./NumGuess.sh: line 7: [: missing `]'
./NumGuess.sh: line 10: [: missing `]'
./NumGuess.sh: line 12: [: missing `]'
Enter In a Number between 10 and 100
I have tried moving the echo "Enter a Number between 10 and 100."
inside the while loop but that did not work. The loop is not looping back to the first if
statement and is just shutting down after it takes the first user input and then producing errors.