How to write a program in bash which draw a number

S

Shozda

Guest
i would like to write a program wchich draws a number on of 100 and than it wirte to user it's too much if its bigger than drawed number or it's to low if number (which wrote user) is lower.
I have stomething like this but I have got errors:

Code:
num=`$((RANDOM/327))`
echo „write a number from 0 -100”
read type
until  [ $num = $type ]
do
if [$num –lt $type]
then echo “too much!”
sleep 1
clear
echo “Try again!”
read type
esle if [$num –gt $type] then
echo “too low!”
sleep 1
echo “Try again!”
read type
fi
fi
done

well I get multiple errors. could anybodie help?
 


Ok quite good working prog is:

Code:
type=$((RANDOM/327))
until [ $num = $type ];
do
clear
echo “give me number from 1-100”
read num
if [$num –lt $type]
then echo -e “to low!”
elif [$num –gt $type]
then
echo –e “to much!”
fi
sleep 1
done

however I have an error because it always pick up 0 (zero) I don't know why. Maybey it's fedora or sth.
 
As grail said "You mention about the user entering numbers in the range 0 - 100 in the script but then have used the number 327??? I am not sure I see the point here?"

RANDOM % 100 + 1
 
Code:
if [ $num –lt $type ]

In the shell, if statement must have spaces.
 

Members online


Top