Currently working on my bash skills. I've done a few activites based on if/elif/else given to me to my tutor but can't put my finger on the one below.
Basically I'm tasked with outputting the following based on the input of a grade. Less than 40% = Fail 40% to 59% = Pass 60% to 69% = Merit 70% and above = Distinction
It seems to get caught on the first elif, presents the grade as merit for anything below 70 and doesn't check the others, it gives the same result when I change the order too.
echo "Please enter your grade"
read GRADE
echo
if [ $GRADE -ge 70 ]; then
echo "Well done, you got a distinction"
elif [ $GRADE -ge 60 ] || [ $GRADE -le 69 ]; then
echo "Well done, you got a merit"
elif [ $GRADE -ge 40 ] || [ $GRADE -le 59 ]; then
echo "Well done, you got a pass"
else
echo "Unfortunately you failed"
fi
||(logical OR), rather than&&(logical AND).[ $GRADE -le ... ]completely. The order of the theelifs already ensures that the grade is less than....>= 60or<=69. You have a logical error there.