Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #student marksheet
- #1. Add
- #2. View
- #3. Update
- #4. Search
- #5. Calculation Percetage
- i=1;
- j=1;
- echo -n "Enter Database Name : "
- read sheet
- while [ $i = 1 ]
- do
- echo "-----------------------------------"
- echo "1. Add Students Record."
- echo "2. View Students Record."
- echo "3. Update Student Record."
- echo "4. Search Student"
- echo "5. Calculation."
- echo "6. Exit."
- echo "-----------------------------------"
- echo -n "Enter Choose : "
- read ch
- case $ch in
- 1) #Add_Record
- echo -n "Enroll : "
- read er;
- echo -n "Student Name : "
- read name;
- echo -n "Subject 1 : "
- read sub1;
- echo -n "Subject 2 : "
- read sub2;
- echo -n "Subject 3 : "
- read sub3;
- echo "$er | $name | $sub1 | $sub2 | $sub3" >> $sheet;
- ;;
- 2) #Display_List
- sort -n -k1 $sheet;
- ;;
- 3) #Update_Command
- sort -n -k1 $sheet;
- echo -n "Enter Student Enroll : "
- read n;
- grep -i "$n" $sheet | tee x;
- wc -c x | tee y;
- a=`cut -d " " -f 1 y`
- if [ "$a" = 0 ]
- then
- echo "Record not found"
- else
- echo -n "Enroll : "
- read er;
- echo -n "Student Name : "
- read name;
- echo -n "Subject 1 : "
- read sub1;
- echo -n "Subject 2 : "
- read sub2;
- echo -n "Subject 3 : "
- read sub3;
- grep -v "$n" $sheet | cat > def;
- cat def | tee $sheet;
- echo "$er | $name | $sub1 | $sub2 | $sub3" >> $sheet;
- sort -n -k1 $sheet;
- fi
- ;;
- 4) #Search Student
- echo -n "Enter Student Enroll : "
- read ers;
- grep "$ers" $sheet > search.txt
- cat search.txt;
- ;;
- 5) #5. Calculation Percetage
- echo -n "Enter Student Enroll : "
- read scal;
- grep "$scal" $sheet > scal.txt
- echo "-----------------------------------"
- cat scal.txt
- echo "-----------------------------------"
- s1=0;
- s2=0;
- s3=0;
- s1=`echo $s1 | cut -d "|" -f3 scal.txt`
- s2=`echo $s2 | cut -d "|" -f4 scal.txt`
- s3=`echo $s3 | cut -d "|" -f5 scal.txt`
- tot=`expr $s1 + $s2 + $s3`;
- per=`expr $tot / 3`;
- echo "Percentage : $per "%"";
- echo "-----------------------------------"
- echo "Working"
- if [ $per -ge 70 || $per -ls 60 ]
- then
- echo "Grade is A";
- fi
- ;;
- *) exit
- ;;
- esac
- echo -n "Do You Want To Conti... (1 Conti.. / 2 Exit) ? "
- read i
- echo "-----------------------------------"
- if [ $i = 0 ]
- then
- exit
- fi
- done
Add Comment
Please, Sign In to add comment