UNIX SHELL PROG. & ELM QUESTIONS

Russell J Fulton;ccc032u russell at ccu1.aukuni.ac.nz
Mon May 13 09:10:36 AEST 1991


rickert at mp.cs.niu.edu (Neil Rickert) writes:

>In article <1991May10.064610.25802 at starnet.uucp> moe at starnet.uucp (Moe S.) writes:
>>2. If I have a file containing some names and email addresses such as
>>   this: 
>>	      xyz at jkjk.jkyu.reyui (John J. Doe)
>>	      Mark L. Lost <apple!mark at eee.dfsjk.jkj>
>>	      Joe!!! jjj at jhdf.434r.er
>>  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? 

> Very difficult.  Probably beyond the abilities it awk, sed, etc.  If
>Larry Wall happens to be reading this he may suggest perl.  The trouble is
>that the syntax of RFC822 addresses is quite complex, and as X.400 gateways
>become more common the extreme cases of RFC822 addresses are increasingly
>likely to show up.

Yes, I would be inclined to use perl or icon. Icon is probably the more
powerful for this sort of thing. You need something with very flexible 
pattern matching.  Your approach depends on whether it is 'one off' or if it
is going to turn into a routine job. If the former it *may* be quicker to
grit your teeth and do it by hand. If not the you may find the time taken 
to write a perl or icon script worthwhile. 

As for choosing between perl and icon, I would say if you are already well
versed in regular expressions and the like go for perl, otherwise icon.

Cheers, Russell
-- 
Russell Fulton, Computer Center, University of Auckland, New Zealand.
<rj_fulton at aukuni.ac.nz>



More information about the Comp.unix.questions mailing list