#!/bin/bash
#----------------------------------------------------------------------#
# True if the file exists and is not a directory #
#----------------------------------------------------------------------#
if [ -s student.txt ]; then
#----------------------------------------------------------------------#
# remove file #
#----------------------------------------------------------------------#
rm student.txt
fi
count=1
while [ $count -le 3 ]; do
#----------------------------------------------------------------------#
# for displying string "Enter the first name" #
#----------------------------------------------------------------------#
echo Enter the first name
read fname
echo Enter the last name
read lname
flag=1
#----------------------------------------------------------------------#
# if the grade is not properly entered(grade should be 0-100), #
# then again grade shold entered correctly #
#----------------------------------------------------------------------#
while [ $flag -ne 0 ]; do
echo Enter the Grade, Grade should be 0-100 read grade
read grade
#----------------------------------------------------------------------#
# checks grade value #
#----------------------------------------------------------------------#
if [ $grade -ge 0 -a $grade -le 100 ]; then
#----------------------------------------------------------------------#
# create student.txt file and then insert/append fname,lname,grade to #
#----------------------------------------------------------------------#
echo $fname $lname $grade >> student.txt
#----------------------------------------------------------------------#
# change the flag value for end the loop #
#----------------------------------------------------------------------#
flag=0
fi
done
#----------------------------------------------------------------------#
# increment counter. #
#----------------------------------------------------------------------#
(( count = count + 1 ))
done
#----------------------------------------------------------------------#
# display the student.txt #
#----------------------------------------------------------------------#
cat student.txt
lots of minor mistakes.
modified your syntax to look more like other languages such as perl, C, awk, etc...
this'll make learning new languages easier in the long run.
Also, added the comment block style. The extra characters are nothing for today's computers,
and hopefully you see how well the comments "pop" out of the programming text this way.
You may want to do a "diff your_script my_script" to see all the differences.
Some were subtle.