|
#!/bin/bash
echo ' Do you wish to add a contact to
the address book? '
read choice1
if [ $choice1 = “y” –o $choice1 = “Y” ]
then
echo ' Please enter the contact
name: '
read contactName
echo ' Please enter the contact
company or organization: '
read contactCompany
echo ' Please enter the contact
telephone number: '
read contactPhone
echo ' Please enter the contact
street address: '
read contactStreet
echo ' Please enter the contact
state and zip code: '
read contactZip
# Now write the contents to a
file via redirection. Below should
all be on same line.
# Note that you need to also have
created an empty text file called "ContactDatabase".
# You could use the "touch" command
for this.
echo -e “Name: $contactName
Company: $contactCompany
Phone: $contactPhone Street:
$contactStreet Zip:
$contactZip” >> ContactDatabase
fi
echo ' Would you like to search for an
entry in the contact database? '
read choice2
if [ $choice2 = “y” –o $choice2 = “Y” ]
then
echo ' What word do you wish to
search for? '
read searchItem
grep $searchItem ContactDatabase
elif [ $choice2 = “n” –o $choice2 = “N”
]
then
echo ' O.k., I guess not. '
else
echo ' That
was not an option. '
fi
|