Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.misc > #11760 > unrolled thread
| Started by | nomdeplume82008@googlemail.com |
|---|---|
| First post | 2014-08-19 10:19 -0700 |
| Last post | 2014-09-29 09:52 +0300 |
| Articles | 6 on this page of 26 — 13 participants |
Back to article view | Back to comp.os.linux.misc
Script to parse a text file and extract unique email addresses nomdeplume82008@googlemail.com - 2014-08-19 10:19 -0700
Re: Script to parse a text file and extract unique email addresses Andreas Kohlbach <aug14.8.ankman@spamgourmet.com> - 2014-08-19 16:40 -0400
Re: Script to parse a text file and extract unique email addresses The Natural Philosopher <tnp@invalid.invalid> - 2014-08-20 14:21 +0100
Re: Script to parse a text file and extract unique email addresses nomdeplume82008@googlemail.com - 2014-08-20 08:52 -0700
Re: Script to parse a text file and extract unique email addresses Andreas Kohlbach <aug14.8.ankman@spamgourmet.com> - 2014-08-20 18:26 -0400
Re: Script to parse a text file and extract unique email addresses nomdeplume82008@googlemail.com - 2014-08-20 21:10 -0700
Re: Script to parse a text file and extract unique email addresses Andreas Kohlbach <aug14.8.ankman@spamgourmet.com> - 2014-08-21 18:07 -0400
Re: Script to parse a text file and extract unique email addresses Tim Watts <tw_usenet@dionic.net> - 2014-08-21 10:53 +0100
Re: Script to parse a text file and extract unique email addresses Andreas Kohlbach <aug14.8.ankman@spamgourmet.com> - 2014-08-21 18:03 -0400
Re: Script to parse a text file and extract unique email addresses Bill Marcum <bill.marcum57@yahoo.com> - 2014-08-21 03:34 -0400
Re: Script to parse a text file and extract unique email addresses The Natural Philosopher <tnp@invalid.invalid> - 2014-08-21 12:12 +0100
Re: Script to parse a text file and extract unique email addresses Chris Davies <chris-usenet@roaima.co.uk> - 2014-08-21 12:12 +0100
Re: Script to parse a text file and extract unique email addresses The Natural Philosopher <tnp@invalid.invalid> - 2014-08-21 14:22 +0100
Write it in C... (Was: Script to parse a text file and extract unique email addresses) gazelle@shell.xmission.com (Kenny McCormack) - 2014-08-21 13:42 +0000
Re: Write it in C... (Was: Script to parse a text file and extract unique email addresses) The Natural Philosopher <tnp@invalid.invalid> - 2014-08-21 15:23 +0100
Re: Write it in C... Rich <rich@example.invalid> - 2014-08-21 16:17 +0000
Re: Write it in C... The Natural Philosopher <tnp@invalid.invalid> - 2014-08-21 18:42 +0100
Re: Write it in C... William Unruh <unruh@invalid.ca> - 2014-08-21 18:38 +0000
Re: Script to parse a text file and extract unique email addresses Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2014-09-24 13:18 +0000
Re: Script to parse a text file and extract unique email addresses Doug Laidlaw <laidlaws@hotkey.net.au> - 2014-09-25 01:49 +1000
Re: Script to parse a text file and extract unique email addresses Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> - 2014-09-25 09:34 +0000
Re: Script to parse a text file and extract unique email addresses Mladen Gogala <gogala.mladen@gmail.com> - 2014-09-29 00:17 +0000
Re: Script to parse a text file and extract unique email addresses Rich <rich@example.invalid> - 2014-09-29 00:52 +0000
Re: Script to parse a text file and extract unique email addresses gazelle@shell.xmission.com (Kenny McCormack) - 2014-09-29 01:13 +0000
Re: Script to parse a text file and extract unique email addresses Tim Watts <tw_usenet@dionic.net> - 2014-09-29 07:40 +0100
Re: Script to parse a text file and extract unique email addresses Eric Pozharski <whynot@pozharski.name> - 2014-09-29 09:52 +0300
Page 2 of 2 — ← Prev page 1 [2]
| From | Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> |
|---|---|
| Date | 2014-09-25 09:34 +0000 |
| Message-ID | <5423e18e$0$2387$426a34cc@news.free.fr> |
| In reply to | #12157 |
Thu, 25 Sep 2014 01:49:36 +1000, Doug Laidlaw did cat : > On 24 Sep 2014 13:18:58 GMT > Loki Harfagr <l0k1@thedarkdesign.free.fr.INVALID> wrote: > >> > It would be best to get the script to extract characters around a @ >> > sign. All of them appear to be enclosed in a <> symbols. >> >> If you're sure about that keypoint (enclosed in diamond) then the >> following script should be safer since it doesn't try to fight >> against the monstruous regexp needed to describe the real possible >> email format: $ gawk '/@/' RS='[<>]' yourfile > > There are Web sites which test for a valid email address. There may be > some ideas there. The Javascript archives are sure to have something. probably but I can't see any relation to the OP question :D)
[toc] | [prev] | [next] | [standalone]
| From | Mladen Gogala <gogala.mladen@gmail.com> |
|---|---|
| Date | 2014-09-29 00:17 +0000 |
| Message-ID | <pan.2014.09.29.00.17.34@gmail.com> |
| In reply to | #11760 |
On Tue, 19 Aug 2014 10:19:24 -0700, nomdeplume82008 wrote:
> Hi all,
>
> My scripting is a v. rusty and I am trying to write a script that will extract unique email addresses from an out Outlook file to build an address book.
>
> In the output file, all the email addresses should preferably be in a single alphabetical column.
>
> Any suggestions on how to do it?
>
> Thanks.
Here is my take:
#!/usr/bin/env perl
use warnings;
use strict;
my %EMAILS;
while (<>) {
if (/([a-z0-9.-]+\@[a-z0-9.-]+)/i) {
if ( !defined( $EMAILS{$1} ) ) {
$EMAILS{$1} = 1;
}
else { next; }
}
else { next; }
}
foreach my $addr ( sort keys %EMAILS ) {
print "$addr\n";
}
--
Mladen Gogala
The Oracle Whisperer
http://mgogala.byethost5.com
[toc] | [prev] | [next] | [standalone]
| From | Rich <rich@example.invalid> |
|---|---|
| Date | 2014-09-29 00:52 +0000 |
| Message-ID | <m0aago$ghn$1@dont-email.me> |
| In reply to | #12180 |
Mladen Gogala <gogala.mladen@gmail.com> wrote:
> On Tue, 19 Aug 2014 10:19:24 -0700, nomdeplume82008 wrote:
> > Hi all,
> >
> > My scripting is a v. rusty and I am trying to write a script that will extract unique email addresses from an out Outlook file to build an address book.
> >
> > In the output file, all the email addresses should preferably be in a single alphabetical column.
> >
> > Any suggestions on how to do it?
> >
> > Thanks.
> Here is my take:
> #!/usr/bin/env perl
> use warnings;
> use strict;
> my %EMAILS;
> while (<>) {
> if (/([a-z0-9.-]+\@[a-z0-9.-]+)/i) {
> if ( !defined( $EMAILS{$1} ) ) {
> $EMAILS{$1} = 1;
> }
> else { next; }
> }
> else { next; }
> }
> foreach my $addr ( sort keys %EMAILS ) {
> print "$addr\n";
> }
Tcl version of your Perl:
puts [join [lsort -unique -nocase [regexp -all -inline {[a-z0-9.-]+@[a-z0-9.-]+} [read stdin]]] \n]
[toc] | [prev] | [next] | [standalone]
| From | gazelle@shell.xmission.com (Kenny McCormack) |
|---|---|
| Date | 2014-09-29 01:13 +0000 |
| Message-ID | <m0abnd$1rh$1@news.xmission.com> |
| In reply to | #12182 |
In article <m0aago$ghn$1@dont-email.me>, Rich <rich@example.invalid> wrote:
...
>Tcl version of your Perl:
>
>puts [join [lsort -unique -nocase [regexp -all -inline {[a-z0-9.-]+@[a-z0-9.-]+}
>[read stdin]]] \n]
Gee, and we always heard and believed that _Perl_ was incomprehensible...
--
"The anti-regulation business ethos is based on the charmingly naive notion
that people will not do unspeakable things for money." - Dana Carpender
Quoted by Paul Ciszek (pciszek at panix dot com). But what I want to know
is why is this diet/low-carb food author doing making pithy political/economic
statements?
Nevertheless, the above quote is dead-on, because, the thing is - business
in one breath tells us they don't need to be regulated (which is to say:
that they can morally self-regulate), then in the next breath tells us that
corporations are amoral entities which have no obligations to anyone except
their officers and shareholders, then in the next breath they tell us they
don't need to be regulated (that they can morally self-regulate) ...
[toc] | [prev] | [next] | [standalone]
| From | Tim Watts <tw_usenet@dionic.net> |
|---|---|
| Date | 2014-09-29 07:40 +0100 |
| Message-ID | <nfbnfb-bur.ln1@squidward.local.dionic.net> |
| In reply to | #12180 |
On 29/09/14 01:17, Mladen Gogala wrote:
> #!/usr/bin/env perl
> use warnings;
> use strict;
> my %EMAILS;
> while (<>) {
> if (/([a-z0-9.-]+\@[a-z0-9.-]+)/i) {
> if ( !defined( $EMAILS{$1} ) ) {
> $EMAILS{$1} = 1;
> }
> else { next; }
> }
> else { next; }
> }
> foreach my $addr ( sort keys %EMAILS ) {
> print "$addr\n";
> }
The domain part of the regex is fine (excepting new fangled unicode
domains).
However the local part (before the @) is lacking a large set of legal
characters.
http://en.wikipedia.org/wiki/Email_address#Local_part
(because it's easier than finding *that* particular RFC).
In particular _ and + are quite common
I often find web script programmers make serious errors as I try to use
one of my email addresses and it barfs.
[toc] | [prev] | [next] | [standalone]
| From | Eric Pozharski <whynot@pozharski.name> |
|---|---|
| Date | 2014-09-29 09:52 +0300 |
| Message-ID | <slrnm2i0d4.78c.whynot@orphan.zombinet> |
| In reply to | #12180 |
with <pan.2014.09.29.00.17.34@gmail.com> Mladen Gogala wrote:
*SKIP*
> Here is my take:
*CUT*
Perl of yours just got two kittens killed.
perl -MList::MoreUtils=uniq -wE '
say foreach uniq sort do { local $/; <> } =~ /([\w.-]+@[\w.-]+)/g'
Doesn't read multiple files on command line (should be fed on STDIN);
regexp is FUBAR.
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.os.linux.misc
csiph-web