大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#/bin/bash #score.sh #color 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" ;; *)echo "invalid colour" ;; esac } #search function search() { colour black_white clear echo -e "please enter name >>>\c" read NAME #wujilu if [ ! -f ./record ];then echo"you must have some scores before you can seach!" sleep 10 clear return fi if [ -z $NAME ];then echo "you did'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 did't enter name to search!" sleep 10 search esac } #add record add() { clear echo -e "enter name and score of a record:\c" if [ ! -f ./record ];then touch record fi read NEWNAME echo "$NEWNAME">./record sort -o ./record ./record } #delete delete() { clear echo -e "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 } #display record display() { colour black_white more ./record sleep 10 } #edit edit() { vi ./record } #help pingmu help() { clear colour black_cyan echo "This is a student's record program by unix shell language" } #exit quit() { clear colour black_white exit } clear while true do colour red_yellow echo "##########################################" echo "# 1:search a record #" echo "# 2:add a record #" echo "# 3:delete a record #" echo "# 4:display all record #" echo "# 5:edit record with vi #" echo "# H:help screen #" echo "# Q:exit pragma #" echo "##########################################" colour black_green echo -e -n "\tplease enter your choice [1 2 3 4 5 H Q]: \c" read CHOICE case $CHOICE in 1)search ;; 2)add; ;; 3)delete;clear ;; 4)display ;; 5)edit;clear ;; H)help ;; Q)quit ;; *)echo "please enter valid mode" ;; esac sleep 10 clear done