addperson
}
function answer ()
{
read
case $REPLY in
y|Y|[Yy][Ee][Ss] ) show ;;
n|N|[Nn][Oo] ) menu ;;
* ) exit 0;;
esac
}
function showname ()
{
showname=`awk -F: -v new=$name '{ if ( $1 == new ) print $0; }' addressbook | awk -F: '{ printf "%-10s%s\n%-10s%s\n%-10s%s\n%-10s%s\n%-10s%s\n%-10s%s\n\n", "Name: ", $1, "E-mail: ",$2, "Address: ", $3, "Phone Number: ", $4, "Moblie Phone Number: ", $5, "Other Messages: ", $6 ; }' `
}
function showall ()
{
awk -F: '{ printf "%-10s%s\n%-10s%s\n%-10s%s\n%-10s%s\n%-10s%s\n%-10s%s\n\n", "Name: ", $1, "E-mail: ",$2, "Address: ", $3, "Phone Number: ", $4, "Moblie Phone Number: ", $5, "Other Messages: ", $6 ; }' addressbook
}
function show ()
{
echo -ne "\33[33mWhose data you want to know ? \n\33[34mType his or her name directly ( Type "all" for check out for all people! ): \33[0m"
read name
if [ -f "addressbook" ]
then
if [ $name == "all" ]
then
showall
echo -e "\33[33mType "y" to check a person's data, and "n" to the main menu, other keys will exit!\33[0m"
answer
else
showname
if [ -z "$showname" ]; then
本文关键:自己编的一个通讯录系统(简陋了点)