自己编的一个通讯录系统(简陋了点)[1]

[入库:2005年9月19日] [更新:2007年3月24日]

本文简介:


为了复习一下自学的shell编程,闲余时间编了个通讯录,主要有三个主体部分,本来想加个编辑功能的,想了想,里面内容这么少,要编辑不如将原来的覆盖不就OK了嘛,简单一个功能却要加几十行,弄得这么麻烦,算了,就下面的了^_^
主函数脚本:
#!/bin/sh
                                                                                                                            
source add
source show
source delete
                                                                                                                            
function menu()
{
echo -e "\33[34m"
cat << EOF
        What you want to do? Please input you choice:
 
                [1] Add a person into the address book!
                [2] Check out a person's data in the address book!
                [3] Delete a person from the origin address book!
                [4] Quit without do anything!
 
EOF
echo -ne "Please select [ 1, 2, 3, or 4 ]:\33[0m"
 
while read choice
        do
                case $choice in
                        1 ) add;;
                        2 ) show ;;
                        3 ) delete ;;
                        4 ) echo ByeBye!; exit 0 ;;
                        * ) echo -ne "\33[31mError! Please input [ 1, 2, 3, or 4 ]:  \33[0m";;
                esac
done
}
 
echo -e "\33[32m\t\tWellcome to My addressbook!\33[0m"
menu

 chauney 回复于:2005-03-18 21:03:14
function checkperson ()
{
        if [ -z "$name" ]; then
                echo -e "\33[31mError! the Name is incorrect!\n Please Input the person's name and other messages again: \33[0m"
                addperson
        fi
        if [ -f "addressbook" ]
                then
                        showname
                        if [ ! -z "$showname" ] ; then
                                echo  "The name you input has already exist! Do you want to delete the origin name? [ y or n or q ( quit to main menu )]"
                                while read
                                do
                                        case $REPLY in
                                                y|Y|[Yy][Ee][Ss] )
                                                        awk -F: -v new=$name '{ if ( $1 != new ) print $0; }' addressbook  > /tmp/tmp$$
                                                        mv -f /tmp/tmp$$ addressbook 2> /dev/null
                                                        check
                                                        identify
                                                ;;
                                                n|N|[Nn][Oo] )
                                                        echo Please input the name again:

本文关键:自己编的一个通讯录系统(简陋了点)
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top