Remove area code using from awk output

I am back again with one more question,

so I have a phonebook file with names, phone\#s

for example: smith, joe 123-456-7890

using awk I want to display all entries with a specific area code. here 's what i have tried so far:

awk '$2~/^123/ {print}' phonebook

I can't figure out how to make the area code disappear and have only the last 7 digits appear as the output. Also is it possible for me to sort it by last name. I am assuming pipe sort with awk. anyone?

Thanks again

You could try something like:

awk '
$NF ~ /^123-/ {
        $NF = substr($NF, 5)
}
1' phonebook | sort

With phonebook containing:

smith, joe 123-456-7890
jones, first middle 123-345-6789
jones, diff a/c 202-303-4004
chan, jackie 123-987-6543

the output produced is:

chan, jackie 987-6543
jones, diff a/c 202-303-4004
jones, first middle 345-6789
smith, joe 456-7890