This is what I currently have so far.
The script needs to Add, Edit, Search, and View the address_file.
Any help would be greatly appreciated.
trap "rm ./f 2> /dev/null; exit" 0 1 3
addressfile=~/address_file
loop=x
while test $loop = "x"
do
clear
tput cup 3 12; echo "Address Book Menu"
tput cup 4 12; echo "================="
tput cup 6 9; echo "S - Search For Address"
tput cup 7 9; echo "A - Add Address"
tput cup 8 9; echo "R - Remove Address"
tput cup 9 9; echo "E - Edit Address"
tput cup 10 9; echo "V - View Address"
tput cup 12 9; echo "Q - Quit"
tput cup 12 19;
read choice || continue
case $choice in
# [Ss] fnSearchPhone ;;
[Aa]) fnPhoneAdd ;;
[Rr]) fnPhoneDelete ;;
# [Ee]) fnEditPhone ;;
[Vv]) fnViewPhone ;;
[Qq]) clear ; exit ;;
*) tput cup 14 4; echo "Invalid Code"; read choice ;;
esac
done
fnPhoneAdd()
{
testloop=y
while [ $looptest = y ]
do
clear
tput cup 1 4; echo "Address Book Phone Addition"
tput cup 2 4; echo "==========================="
tput cup 4 4; echo "Full Name : "
tput cup 5 4; echo "Phone Number: "
tput cup 6 4; echo "Office : "
tput cup 8 4; echo "Add Another? (y)es or (q)uit: "
tput cup 4 18; read phonenum
if [ "$phonenum" = "q" ]
then
clear ; exit
fi
tput cup 4 18; read name
tput cup 5 18; phonenum
tput cup 6 18; office
if [ "$name} > " " ]
then
echo "$name:$phonenum:$office" >> $addressfile
fi
tput cup 12 33; read testloop
if [ "$testloop" = "q"]
then
clear ; exit
fi
done
}
fnPhoneDelete
{
tput cup 16 4; echo "Delete Address Book Record"
tput cup 17 4; echo "Phone: "
tput cup 17 11; read phonenum
tput cup 18 4; echo "Accept? (y)es or (n)o: "
tput cup 18 27; read Accept
if test $Accept = "y"
then
sed /$number/d $addressfile > f
cp f $addressfile
rm f
fi
;;
}
fnViewPhone
{
clear ; less $addressfile
}