I have created an awk script to parse through a contacts list that looks like the example below.
Full Name: Joe Schmoe
Last Name: Schmoe
First Name: Joe
Job Title: Vice President
Company: JS Inc.
Business: (999) 999-9999
E-mail: jschmoe@js.com
Full Name: Henry Schmoe
Last Name: Schmoe
First Name: Henry
Mobile: (999) 999-9999
E-mail: jschmoe@js.com
When I parse this input using my awk script, if the second record does not have a value for something that is in the first record, the value for the first record is used. Basically, I just need to know how to "unset" the variable.
Below is my awk script.
Any help would be greatly appreciated.
Thanks,
John
Full Name: Joe Schmoe
Last Name: Schmoe
First Name: Joe
Job Title: Vice President
Company: JS Inc.
Business: (999) 999-9999
E-mail: jschmoe@js.com
Full Name: Henry Schmoe
Last Name: Schmoe
First Name: Henry
Mobile: (999) 999-9999
E-mail: jschmoe@js.com
When I parse this input using my awk script, if the second record does not have a value for something that is in the first record, the value for the first record is used. Basically, I just need to know how to "unset" the variable.
Below is my awk script.
Code:
BEGIN{printf "%-18s %-12s %-12s %-12s %-12s\n", "Name", "Work", "Cell", "Home",
"E-Mail\n==============================================================================="}
/Full Name:/{name = $3" "$4}
/Business:/{if ($3=="Ext") business = $2;if ($2 ~ /[0-9]{3}/) business = $2" "$3
; else business = ""}
/Home:/{if ($2 ~ /[0-9]{3}/) home = $2" "$3; else home = ""}
/Mobile:/{if ($2 ~ /[0-9]{3}/) cell = $2" "$3; else cell = ""}
/E-mail:/{email= $2; printf "%-18s %-12s %-12s %-12s %-12s\n", name, business, h
ome, cell, email}
Any help would be greatly appreciated.
Thanks,
John