shell脚本:简单的分数记录系统-创新互联
直接上代码:
创新互联建站成都网站建设按需网站建设,是成都网站设计公司,为发电机维修提供网站建设服务,有成熟的网站定制合作流程,提供网站定制设计服务:原型图制作、网站创意设计、前端HTML5制作、后台程序开发等。成都网站营销推广热线:13518219792#mcore.sh #!bin/bash function colour() { case $1 in black_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_white clear echo -e "please enter name >>>\c" read NAME if [ ! -f ./record ]; then echo "you must have some scores before you can search" sleep 2 clear return fi if [ -z "$NAME" ]; then echo "you didn t enter a name!" echo -e "please enter name >>>\c" read NAME fi grep -i "$NAME" ./record 2> /dev/null case "$?" in 1) echo "Name not in record" ;; 2) echo "you didin t enter a name to search" search;; esac } function add() { clear echo "enter name and score of a record" echo -e "\c" if [ ! -f ./record ];then touch record fi read NEWNAME echo "$NEWNAME" >./record sort -o ./record ./record } function delete() { clear echo -m "please enter name >>\c" read NAME if [ ! -f ./record ];then echo "this name is not in record" else cp record record.bak rm -f record grep -v "$NAME" ./record.bak > record rm -f record.bak fi } function display() { colour black_white more ./record } function edit() { vi ./record } function help() { clear colour black_cyan echo "this is a student s record program by lunix shell language" } function quit() { clear colour black_white exit } clear while true do colour red_yellow echo "****************************************" echo "*STUDENT S RECORD MENU *" echo "****************************************" colour yellow_blue echo "****************************************" 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_green echo -e -n "\tplease enter you choice 1--5,H,Q:\c" read CHOICE case $CHOICE in 1) search;; 2) add; clear;; 3) delete; clear;; 4) display;; 5) edit; clear;; H | h) help;; Q | q) quit;; *) echo "invalid choice"; sleep 2; clear;; esac done
运行结果:
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
本文题目:shell脚本:简单的分数记录系统-创新互联
链接URL:http://myzitong.com/article/dgpoig.html