Virajsinh

Shell_Script_OS_Database_2

Nov 12th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. i=1;
  2. j=1;
  3. echo -n "Enter Database Name : "
  4. read jdg
  5.  
  6. while [ $i = 1 ]
  7. do
  8. echo "-----------------------------------"
  9. echo "1. Add Judge Record."
  10. echo "2. View Judge Record."
  11. echo "3. Find Highest Case."
  12. echo "4. Calculate Total Case Of Court "Ahmedabad"."
  13. echo "5. List Judge Names."
  14. echo "6. Update Judge Record."
  15. echo "7. Exit."
  16. echo "-----------------------------------"
  17. echo -n "Enter Choose : "
  18. read ch
  19.  
  20. case $ch in
  21.  
  22. 1) #Add_Record
  23. echo -n "Judge_Name : "
  24. read jd_name;
  25.  
  26. echo -n "Court_Name : "
  27. read crt_name;
  28.  
  29. echo -n "Court_City : "
  30. read crt_city;
  31.  
  32. echo -n "Case_Of_Judge : "
  33. read cas_judge;
  34.  
  35. echo -n "Total_Case : "
  36. read ttl_case;
  37.  
  38. #must see this format other wise cannot work awk command
  39. echo "$jd_name | $crt_name | $crt_city | $cas_judge | $ttl_case" >> $jdg;
  40. ;;
  41.  
  42. 2) #Display_List
  43. sort -n -k1 $jdg;
  44. ;;
  45.  
  46. 3) #Find Highest Case.
  47. sort --reverse -n -k 4 $jdg > sortname.txt
  48. head -1 sortname.txt > headjudge.txt
  49. cut -d "|" -f1,4 headjudge.txt
  50. ;;
  51.  
  52. 4) #Calculate Total Case Of Court "Ahmedabad"
  53. #use store data in textfile for must see text file save format.
  54. #use this sign must use Space any other operator Ex. " | " other wise awk command not work.
  55. grep -i "Ahmedabad" $jdg > textcity.txt
  56. awk '{s+=$9}END{print s}' textcity.txt
  57. ;;
  58.  
  59. 5) #List Judge Name
  60. cut -d "|" -f1 $jdg > JudgeName.txt
  61. cat JudgeName.txt
  62. ;;
  63.  
  64.  
  65. 6) #Update_Command
  66. sort -n -k1 $jdg;
  67. echo -n "Enter Judge_Name : "
  68. read n;
  69.  
  70. grep -i "$n" $jdg | tee x;
  71. wc -c x | tee y;
  72. a=`cut -d " " -f 1 y`
  73. if [ "$a" = 0 ]
  74. then
  75. echo "Record not found"
  76. else
  77. echo -n "Judge_Name : "
  78. read jd_name;
  79.  
  80. echo -n "Court_Name : "
  81. read crt_name;
  82.  
  83. echo -n "Court_City : "
  84. read crt_city;
  85.  
  86. echo -n "Case_Of_Judge : "
  87. read cas_judge;
  88.  
  89. echo -n "Total_Case : "
  90. read ttl_case;
  91.  
  92. grep -v "$n" $jdg | cat > def;
  93. cat def | tee $jdg;
  94. echo "$jd_name|$crt_name|$crt_city|$cas_judge|$ttl_case" >> $jdg;
  95. sort -n -k1 $jdg;
  96. fi
  97. ;;
  98.  
  99. *) exit
  100. ;;
  101.  
  102. esac
  103.  
  104. echo -n "Do You Want To Conti...?"
  105. read i
  106. echo "-----------------------------------"
  107. if [ $i = 0 ]
  108. then
  109. exit
  110. fi
  111. done
Add Comment
Please, Sign In to add comment