[Gllug] strip invalid email addresses

countd countd42 at googlemail.com
Fri Dec 7 18:28:50 UTC 2007


On Dec 7, 2007 5:59 PM, - Tethys <tethys at gmail.com> wrote:
> On Dec 7, 2007 5:21 PM, countd <countd42 at googlemail.com> wrote:
>
> > I have a plain text list of email addresses. Can anyone help me with a
> > one liner (sed?) to strip out the invalid ones? I can see for example
> > that there are telephone numbers in there, and lines with no @ sign
> > which I'd like to get rid of.
>
> This is actually harder than you'd expect (although not as hard as
> some misinformed pages on the net would have you believe). This is a
> simple regexp that will catch 99% of valid Internet email addresses.
> It's fine for filtering out valid addresses from a list like this
> (accepting that it'll miss a few valid ones), but don't even think
> about using it to validate an address in real time on a wbe form or
> similar, for example.
>
> sed -rn '/^.*@[-A-Za-z0-9]+\.[-A-Za-z0-9.]+$/p' addr.txt

Thanks very much (and to all other respondents) - this will do nicely. It
doesn't have to be perfect  - obviously all invalid addresses will not deliver,
but I had a list of around 8000 addresses for our company crimble letter
and I thought that throwing away the really obvious non-addresses might
be sensible. In particular, I wanted to avoid going through and deleting
invalids!

Cheers all, have a good weekend.
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list