echo "Please enter a number between 0 & 100 followed by [ENTER]:”
read NUMBER

case $NUMBER in
   -ge 0 –le 49) echo "F”;;
   -ge 50 –le 59) echo "D”;;
   -ge 60 –le 69) echo "C”;;
   -ge 70 –le 79) echo "B”;;
   -ge 80 –le 100) echo "A”
esac

its syntax error near 0 thats coming up

thanks all

Recommended Answers

All 2 Replies

1. read will receive a string, not an integer
2. use if statements, i.e. if [ $NUMBER -ge 0 ] && [ $NUMBER -le 49 ]; then echo "F"; elif [] && []; then echo "D"; elif...

Case labels are basically simple regex's.

So you might be able to do this

[0-4]*) echo "F”;;
   5*) echo "D”;;
   6*) echo "C”;;
   7*) echo "B”;;
   [89]*) echo "A”;;

But the if/else logic is a bit safer, and more intuitive.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.