Build a phonebook utility that allows you to access and modify a list of names, addresses, and telephone numbers. Your utility can be an awk script or a combination of unix scripting, awk, and other utilities.
Modifications possible must include but are not limited to:
adding entries
deleting entries
listing the phonebook in alphabetical order
finding specific entries
Answer:
Adding.sh
#phone book name
PHONEBOOK="phoneBook.txt"
#Assigns varaible for NAME and asking user to enter NAME
echo -n"Person's Name:"
read PerName
#Assigns varaible for ADDRESS and asking user to enter ADDRESS
echo -n"Person's Address:"
read PerAddress
#Assigns varaible for NAME and asking user to enter NAME
echo -n"Person's Number:"
read PerNumber
echo" enter values:"
echo -e"$PerName;$PerAddress;$PerNumber "
echo-n "y/n:"
read PerAnswer
if["PerAnswer=="y"]
then
#Writing VALUES to Phone BOOK
echo"$PerName;$PerAddress;$PerNumber>>PHONEBOOK
else
#Message FOR User
echo "$$PerName;$PerAddress;$PerNumber NOT Included to book
fi exit 0
listing.sh
#phone book name
PHONEBOOK="phoneBook.txt"
#NUMBER format before the data
echo"Line Number: Name; Address;phone number"
#Listing In alphabetical order
Sort PHONEBOOK.txt#Printing the PhoneBook with LINE numbera and less paused
n1--numb-separator=": "$PHONEBOOK |less
finding.sh
#phone book name
PHONEBOOK="phoneBook.txt"
#Ask the USER to looking for
echo -n "Which PERSON you need to Find:"
read Perfind
#Printing HEADER before the Ans
grep -i $PerFind $PHONEBOOK
Deleting.sh
#phone book name
PHONEBOOK="phoneBook.txt"
#ASK user to delete a specific line
echo -n"Which LINE wants to delete"
read numb
#RENAME before DELETE
mv $PHONEBOOK myphoneBook.txt
#ADDING line_NUMBers and again deleting number
nl--numb-separator=":"myphoneBook.txt|grep -v $numb:|awk -F:'{print $2}'
PhoneBook.sh
#phone book name
PHONEBOOK="phoneBook.txt"
exit=0
while [ $exit -ne 1 ]
do
echo "What OPERATION do you want to Perform?"
echo -e "adding, listing, finding, deleting, exit:
" read Fanswer
if [ "$Fanswer" = "adding" ]
then
./adding.sh
elif [ "$Fanswer" = "listing" ]
then
./listing.sh
elif [ "$Fanswer" = "finding" ]
then
./finding.sh
elif [ "$Fanswer" = "deleting" ]
then
./deleting.sh
elif [ "$Fanswer" = "exit" ]
then
#EXIT val set to 1
exit=1
else
#ALERT message
echo " SORRY!I do not UNDERSTAND the command."
fi
done
#Out from script
exit 0
Build a phonebook utility that allows you to access and modify a list of names, addresses,...