[Mailman-Users] shell script to make consolidated list from other lists?

John Dell jdell at unr.edu
Fri Dec 5 21:22:28 CET 2003


On Friday 05 December 2003 01:01 am, Simon White wrote:
> 04-Dec-03 at 15:43, Dennis Black (dennis.black at ualberta.ca) wrote :
> Hmmm
>
> uniq -u means print only unique lines. uniq -d means only duplicate
> lines. uniq only works well if sort is applied first. add_members /
> sync_members will ignore dupes anyway (but sort then uniq might be
> quicker). tr is not obligatory but I can see what you're getting at
> (changing case so that everyone's emails are in lower case for both
> lists).

Yep, I noticed this problem also in testing.

> I'd do something a bit more like (replace $prefix with path to mailman)
>
> # get member lists into the temp file
> $prefix/bin/list_members the-a-list > /tmp/abc.wk1
> $prefix/bin/list_members the-b-list >> /tmp/abc.wk1
>
> # convert everything to lower case
> tr '[A-Z]' '[a-z]' < /tmp/abc.wk1 > /tmp/abc.wk2

I noticed in mm 2.1.x that list_members returns all lowercase unless you 
provide a flag to return original case as entered, so this isn't necessary.

> # deduplicate from 2nd temp file and overwrite 1st temp file, to save
> # counting upwards all the time; we could do this on one line and pipe
> # to another pipe and so on... but separating isn't such a bad thing
> sort -d /tmp/abc.wk2 | uniq > /tmp/abc.wk1
>
> # now sync back to the list
> $prefix/bin/sync_members -w=no -f /tmp/abc.wk1 the-big-list

I now have a working script!  So thanks again to all for your ideas and 
feedback!

Regards,
John





More information about the Mailman-Users mailing list