Virajsinh

Shell_Script_OS_Database_4

Nov 27th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. #student marksheet
  2.  
  3. #1. Add
  4. #2. View
  5. #3. Update
  6. #4. Search
  7. #5. Calculation Percetage
  8.  
  9.  
  10. i=1;
  11. j=1;
  12. echo -n "Enter Database Name : "
  13. read sheet
  14.  
  15. while [ $i = 1 ]
  16. do
  17. echo "-----------------------------------"
  18. echo "1. Add Students Record."
  19. echo "2. View Students Record."
  20. echo "3. Update Student Record."
  21. echo "4. Search Student"
  22. echo "5. Calculation."
  23. echo "6. Exit."
  24. echo "-----------------------------------"
  25. echo -n "Enter Choose : "
  26. read ch
  27.  
  28. case $ch in
  29.  
  30. 1) #Add_Record
  31. echo -n "Enroll : "
  32. read er;
  33.  
  34. echo -n "Student Name : "
  35. read name;
  36.  
  37. echo -n "Subject 1 : "
  38. read sub1;
  39.  
  40. echo -n "Subject 2 : "
  41. read sub2;
  42.  
  43. echo -n "Subject 3 : "
  44. read sub3;
  45.  
  46. echo "$er | $name | $sub1 | $sub2 | $sub3" >> $sheet;
  47. ;;
  48.  
  49. 2) #Display_List
  50. sort -n -k1 $sheet;
  51. ;;
  52.  
  53. 3) #Update_Command
  54. sort -n -k1 $sheet;
  55. echo -n "Enter Student Enroll : "
  56. read n;
  57.  
  58. grep -i "$n" $sheet | tee x;
  59. wc -c x | tee y;
  60. a=`cut -d " " -f 1 y`
  61. if [ "$a" = 0 ]
  62. then
  63. echo "Record not found"
  64. else
  65. echo -n "Enroll : "
  66. read er;
  67.  
  68. echo -n "Student Name : "
  69. read name;
  70.  
  71. echo -n "Subject 1 : "
  72. read sub1;
  73.  
  74. echo -n "Subject 2 : "
  75. read sub2;
  76.  
  77. echo -n "Subject 3 : "
  78. read sub3;
  79.  
  80. grep -v "$n" $sheet | cat > def;
  81. cat def | tee $sheet;
  82. echo "$er | $name | $sub1 | $sub2 | $sub3" >> $sheet;
  83. sort -n -k1 $sheet;
  84. fi
  85. ;;
  86.  
  87. 4) #Search Student
  88. echo -n "Enter Student Enroll : "
  89. read ers;
  90. grep "$ers" $sheet > search.txt
  91. cat search.txt;
  92. ;;
  93.  
  94. 5) #5. Calculation Percetage
  95. echo -n "Enter Student Enroll : "
  96. read scal;
  97.  
  98. grep "$scal" $sheet > scal.txt
  99. echo "-----------------------------------"
  100. cat scal.txt
  101. echo "-----------------------------------"
  102. s1=0;
  103. s2=0;
  104. s3=0;
  105. s1=`echo $s1 | cut -d "|" -f3 scal.txt`
  106. s2=`echo $s2 | cut -d "|" -f4 scal.txt`
  107. s3=`echo $s3 | cut -d "|" -f5 scal.txt`
  108.  
  109. tot=`expr $s1 + $s2 + $s3`;
  110. per=`expr $tot / 3`;
  111. echo "Percentage : $per "%"";
  112. echo "-----------------------------------"
  113.  
  114. echo "Working"
  115. if [ $per -ge 70 || $per -ls 60 ]
  116. then
  117. echo "Grade is A";
  118. fi
  119. ;;
  120.  
  121. *) exit
  122. ;;
  123.  
  124.  
  125. esac
  126.  
  127. echo -n "Do You Want To Conti... (1 Conti.. / 2 Exit) ? "
  128. read i
  129. echo "-----------------------------------"
  130. if [ $i = 0 ]
  131. then
  132. exit
  133. fi
  134. done
Add Comment
Please, Sign In to add comment