Awk to extract contact and put into pipe delimited file
"Geoffrey Scott" <[email protected]> Fri, 29 Sep 2006 14:57:46 +1000
| Newsgroups | gmane.org.user-groups.mlug.main |
|---|---|
| Message-ID | <9DE681DC93551E4FA4C5B50D8BD90F30305D85@gfh-mail-01.guestsfurniturehire.com.au> |
Got another curly one for the script experts amongst us... I need to extract contact details from emails that are sent in plain text formatted thus: Sender's IP Address =3D 203.465.229.57 ------------------------------------------------------------------ to : =3D [email protected] ------------------------------------------------------------------ Name : =3D christina tamagotchi ------------------------------------------------------------------ Business : =3D ------------------------------------------------------------------ PostalAddress : =3D 50 carrot road ------------------------------------------------------------------ Suburb : =3D land of oz=20 ------------------------------------------------------------------ Postcode : =3D 3167 ------------------------------------------------------------------ State : =3D OZ ------------------------------------------------------------------ Telephone : =3D ------------------------------------------------------------------ Mobile : =3D 0412345565 ------------------------------------------------------------------ Email : =3D [email protected] ------------------------------------------------------------------ OptIn : =3D checkbox ------------------------------------------------------------------ Submit : =3D Submit=20 Now I did an awk script like this called maillist.awk: BEGIN { FS =3D " :"; RS =3D "--------------------------------------" } /^Name/ { nam =3D ($2) } /^Business/ { bus =3D ($2) } /^PostalAddress/ { post =3D ($2) } /^Suburb/ { suburb =3D ($2) } /^Postcode/ { postc =3D ($2) } /^State/ { state =3D ($2) } /^Telephone/ { tel =3D ($2) } /^Mobile/ { mob =3D ($2) } /^Email/ { mail =3D ($2) print nam "|" bus "|" post "|" suburb "|" postc "|" state "|" tel "|" mob "|" mail } But it doesn't print anything into the output file. Why would that be? I'm guessing that it is something to do with the formatting of the original text. Any ideas? Regards Geoff=20