Xref: utzoo comp.unix.questions:31273 comp.unix.shell:2162 comp.unix.wizards:25570 comp.unix.programmer:1814 comp.mail.elm:4114 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!newstop!central!convex!felps From: felps@convex.com (Robert Felps) Newsgroups: comp.unix.questions,comp.unix.shell,comp.unix.wizards,comp.unix.programmer,comp.mail.elm Subject: Re: UNIX SHELL PROG. & ELM QUESTIONS Message-ID: Date: 13 May 91 12:50:11 GMT References: <1991May10.064610.25802@starnet.uucp> Sender: usenet@convex.com (news access account) Organization: CONVEX Computer Corporation, Richardson, Tx., USA Lines: 82 Nntp-Posting-Host: mikey.convex.com In <1991May10.064610.25802@starnet.uucp> moe@starnet.uucp (Moe S.) writes: >I appreciate any help on these questions: >1. If I have a large (500+ messages) in a mailbox-format file, > what is the best way to mail a file to everyone of the 500+? > (using elm or any other way). Sounds like your #2 questions is will answer this. Strip the addresses out then send the message to them. The problem is the limit of 550+ addresses by most mailers. I'd try writing a script to strip the addresses put them in a file, split the file, then feed the files as arguments to ucb/mail with a -s "subject" argument too. >2. If I have a file containing some names and email addresses such as > this: > > xyz@jkjk.jkyu.reyui (John J. Doe) > Mark L. Lost > Joe!!! jjj@jhdf.434r.er > (Such a file can be obtained by doing > grep "^From:" mailbox_file ) > How can I re-organize the file (using awk, sed, etc...) so that > the email addresses are the first field in every line in the file? > Note that all addresses will contain at least one of the two > characters: "@" or "!". > Let's say the file is too big to make manual editing practical. Hmmm. I noticed others posted suggestions of PERL or icon. I don't see this as much a language question as I do a standard format and the unexpected non-conformance to that standard. Someone touched on this with the reference to the RFC. Here's is quick shot that gets a large percentage of the addresses but it doesn't handle all of the off the wall cases. for example, I ran it through my $MAIL file and had a blank line in the output. When I looked at what caused it I had a message with the line, From: Roger Rabbit is expecting to see you later today..... from a wonderful secretary that could care less if the mailer uses the From: header. So those are going to be difficult to message out or catch. Here's the code, unfortunately it uses nawk because of the Field Separator: --------------------------------- cut here ---------------------------------- nawk 'BEGIN { FS="[ ()<>:]" # space, tab, left/right paren, left/rigth angles, colon } /^F[rR][oO][mM]:/ { for ( i = 1; i <= NF; i++ ) { if ( index($i,"@") ) { print $i break } else if ( index($i,"!") ) { print $i break } } # print "i="i " NF="NF # print if ( i > NF ) if ( length($2) ) print $2 else print $3 }' $MAIL --------------------------------- cut here ---------------------------------- If you don't have nawk and you don't know awk send me mail and I'll convert it to awk (old awk). >Thanks again. >Moe Hope it helps, Robert Felps I do not speak for felps@convex.com Convex Computer Corp Convex and I seldom Product Specialist 3000 Waterview Parkway speak for myself. Tech. Assistant Ctr Richardson, Tx. 75080 VMS? What's that? 1(800) 952-0379