Re: [Evolution] Can I extract email addresses from emails?



Try this rather 'c' perl, which also handles folded lines and removes
duplicates.

perl -e '$,="\n";$\="\n";while(<STDIN>){if(/^(to|from|cc):/i){$a=$_;}elsif(defined($a)){if(/^[ \t]/){ 
$a.=$_;}else{print$a=~/[\w-\ ]+ [\w-\ ]+/g;undef$a}}}' < ~/evolution/local/Inbox/mbox | sort -u


On Fri, 2003-09-05 at 03:18, Toby A Inkster wrote:
On Thu, 2003-09-04 at 17:50, guenther wrote:
However, just started playing with this topic, as I got curious. This
perl one-liner does the trick pretty well -- although it will catch
unwanted header infos (like Message-Id:) as well, if it looks like a
valid email address.

$ perl -ne 'print "$1\n" while ( s/([\w.-]+@([\w-]+\.)+\w{2,})// )' ~/evolution/local/Inbox/mbox

Better:

egrep -vi '((Message-ID)|(References)|(X-Evolution-Source))\:' ~/evolution/local/Inbox/mbox | perl -ne 
'print "$1\n" while ( s/([\w.-]+@([\w-]+\.)+\w{2,})// )

Still by no means perfect.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]