- ÂÛ̳»ÕÕÂ:
- 0
|
ͨѶ¼ϵͳ½Å±¾£¨Ð޸İ棩
function confirm ()
{
response
if [ "$answer" = "y" ]; then
show
else menu
fi
}
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, " hone Number: ", $4, "Moblie Phone Number: ", $5, "Other Messages: ", $6 ; }' `
if [ -z "$showname" ]; then
return 1
else return 0
fi
}
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, " hone Number: ", $4, "Moblie Phone Number: ", $5, "Other Messages: ", $6 ; }' addressbook
}
function show ()
{
echo -ne "\33[33mWhose data you want to know ? \33[34mType his or her name directly \n\33[0m[ Type "all" to show all data, and No input will skip to main menu!]: "
read name
if [ "$name" == "all" ]; then
showall
echo -e "\33[33mContinue to check out datus? \33[0m[ "y" to continue and "q" will return to the main menu ]"
confirm
elif [ -z "$name" ]; then
menu
else
showname
if [ $? -eq 1 ]; then
echo -e "\33[31mThe person you want to know does not exist! \33[34mCheck again!\33[0m"
show
else
echo -e "$showname"
echo "Do you want to check another person's data? [ "y" to continue and "q" will return to the main menu ]"
confirm
fi
fi
} |
|