Shell script: A simple score recording system

Source: Internet
Author: User

Directly on the code:

#mcore. Sh#!bin/bashfunction colour () {case $1 inblack_white)  echo -e  "\033[40;37m ";; Black_green) echo -e  "\033[40;32m";; Black_cyan) echo -e  "\033[40;36m";; Red_yellow) echo -e  "\033[41;33m";; Yellow_blue) echo -e  "\033[43;34m";; Esac}function search () {colour black_whiteclearecho -e  "please enter name  >>>\c "read nameif [ ! -f ./record ]; thenecho " You must  have some scores before you can search "Sleep 2clearreturn fiif  [ -z  "$NAME"  ]; thenecho  "you didn t enter a name!" echo -e  "please enter name >>>\c" read namefigrep -i  "$NAME"  ./record 2> /dev/nullcase  "$?"  in1) echo  "Name not in record";; 2)  echo  "You didin t enter a name to search "search;; Esac}function add () {clearecho  "Enter name and score of a record" Echo  -e  "\c" If [ ! -f ./record ];thentouch recordfiread newnameecho   "$NEWNAME"  >./recordsort -o ./record ./record}function delete () {Clearecho  -m  "Please enter name >>\c" read nameif [ ! -f ./ record ];thenecho  "This name is not in record" elsecp record  record.bakrm -f recordgrep -v  "$NAME"  ./record.bak > recordrm -f  record.bakfi}function display () {Colour black_whitemore ./record}function edit () {VI  ./record}function help () {clearcolour black_cyanecho  "this is a student  s record program by lunix shell language "}function quit () {Clearcolour black_whiteexit}clearwhile truedo colour red_yellowecho  "************************ "echo " *student s record menu                  * "echo " ************************************* "colour yellow_blueecho " **************************************** "echo " *1:search a  record                      * "echo " *2:add a record                         * "Echo   "*3:delete a recore                      * "echo " *4:dispaly all records                   * "echo " *5:edit record witm  vi                  * "echo " *h:help screen                          * "echo " *Q:exit program                          * "echo " **************************************** "Colour black_ greenecho -e -n  "\tplease enter you choice 1--5,h,q:\c" read CHOICEcase   $CHOICE  in1)  search;; 2)  add; clear;; 3)  delete; clear;; 4)  display;; 5)  edit; clear;; H | H)  help;; Q | Q)  quit;; *) echo  "Invalid choice"; sleep 2;clear;; Esacdone

Operation Result:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/83/0B/wKioL1dpXTuQEFtoAABLUPTAfHo211.png "style=" float: none; "title=" QQ picture 20160621232137.png "alt=" Wkiol1dpxtuqeftoaabluptafho211.png "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/83/0C/wKiom1dpXTzwq3KdAAAhnAeYGyE607.png "style=" float: none; "title=" QQ picture 20160621232241.png "alt=" Wkiom1dpxtzwq3kdaaahnaeygye607.png "/>


This article is from the "egg-left" blog, please be sure to keep this source http://memory73.blog.51cto.com/10530560/1791539

Shell script: A simple score recording system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.