[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

shell programming question

I was wondering if someone could help me with this shell programming
language question. I am trying to remove some entries from a database
Here is what the database file looks like:

Joe,Walsh,134 Mockingbird Way,New Orleans,LA,33456,(444)768-1287
Becky,Walsh,432 Rodeo Drive Apt C,Hollywood,CA,90312,(555)555-5555

Here is the function that I am using to remove one of the entries.
Instead of removing only one of the entries it removes both. It does 
this because I am removing the entries by lastname. SO if more than
one person has the same last name they will all be deleted instead
of just the one I want. I need to know if there is a way to modify
this script to delete entries by first and last name, not just the
last name.

Here is the script.

remove_records() {
  if [ -z "$lastname" ]; then
    echo You must select an address first
    find_ad n
  if [ -n "$lastname" ]; then
    echo "You are about to delete $firstname $lastname"
    get_confirm && {
      egrep -f "$firstname" "$lastname" $address_file > $temp_file
      mv $temp_file $address_file
      echo Entry removed


You only get one chance at life, but if you do it right, you only need one.
Debian GNU/Linux				http://www.naples.net/~nfn11988			

Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null

Reply to: