RE: Awk to extract contact and put into pipe delimited file
"Geoffrey Scott" <[email protected]> Sun, 1 Oct 2006 00:42:33 +1000
| Newsgroups | gmane.org.user-groups.mlug.main |
|---|---|
| Message-ID | <9DE681DC93551E4FA4C5B50D8BD90F30305DD7@gfh-mail-01.guestsfurniturehire.com.au> |
Rod Smart wrote:
> Geoffrey Scott wrote:
>=20
>> Got another curly one for the script experts amongst us...
>>=20
>> I need to extract contact details from emails that are sent in plain
>> text formatted thus:=20
>>=20
>> Sender's IP Address =3D 203.465.229.57
>> }
>>=20
>> /^Email/ {
>> mail =3D ($2)
>> print nam "|" bus "|" post "|" suburb "|" postc "|" state "|" tel
>> "|" mob "|" mail }
>>=20
>>=20
>> 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?=20
>>=20
>>=20
>>=20
>> Regards Geoff
>>=20
>>=20
> May be too simple, or I'm wrong, 50% chance :P
>=20
> The print is inside the "Email" search item
>=20
> /^Email/ {
> mail =3D ($2)
> print nam "|" bus "|" post "|" suburb "|" postc "|" state "|" tel "|"
> mob "|" mail
> }
>=20
> Maybe it should have been here ?
>=20
> /^Email/ {
> mail =3D ($2)
> }
>=20
> print nam "|" bus "|" post "|" suburb "|" postc "|" state "|" tel "|"
> mob "|" mail=20
The example I found on the net had it listed as part of the last regex
and definition of what was going to be printed. It did actually work
for me with a previous bit of text that was formatted in a different way
which I had success with. I went over this for ages trying to figure
out what was wrong and couldn't find it. During all of this I had gone
and used Vim's replace function to format the text in the source file a
bit nicer and take out all the spaces and dashes and crap. Just now I
tried running the awk script on that text and it worked! So I'm still
in the dark as to why it is working now and what I did to fix it. I
hate lucky flukes, I won't know how to reproduce it in the future.....
Regards Geoff