Cory Petkovsek wrote:

> What is the limit on streams?
> 
> Here's what I'm intending to do and perhaps someone has a better solution:
> I have a list of email addresses for a virtual email host:
> 
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> 
> I want to group by domain, append an ' OK' and insert a '$domain REJECT' after
> each domain block.  The output should look like this:
> 
> [EMAIL PROTECTED] OK
> [EMAIL PROTECTED] OK
> [EMAIL PROTECTED] OK
> happy.com REJECT
> [EMAIL PROTECTED] OK
> blah.com REJECT
> [EMAIL PROTECTED] OK
> test.org REJECT

This seems like a task that is simple in Python or Perl, but less
simple as a shell script.  Assuming you have the first file above as
stdin, either of the attached scripts produces the second file.

-- 
Bob Miller                              K<bob>
kbobsoft software consulting
http://kbobsoft.com                     [EMAIL PROTECTED]
#!/usr/bin/env python

import fileinput

users = {}

for line in fileinput.input():
    addr = line.strip()
    domain = addr.split('@')[-1]
    users.setdefault(domain, []).append(addr)

domains = users.keys()
domains.sort()                          # Sort domains so successive
                                        # versions of this file can be
                                        # diff'ed.

for domain in domains:
    u = users[domain]
    u.sort()                            # Sort users for the same reason.
    for user in u:
        print user, 'OK'
    print domain, 'REJECT'

Attachment: cory.pl
Description: Perl program

_______________________________________________
EuG-LUG mailing list
[EMAIL PROTECTED]
http://mailman.efn.org/cgi-bin/listinfo/eug-lug

Reply via email to