Xref: utzoo comp.unix.questions:31261 comp.unix.shell:2160 comp.unix.wizards:25560 comp.unix.programmer:1811 comp.mail.elm:4110 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!comp.vuw.ac.nz!waikato.ac.nz!aukuni.ac.nz!russell From: russell@ccu1.aukuni.ac.nz (Russell J Fulton;ccc032u) 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: <1991May12.231036.6174@ccu1.aukuni.ac.nz> Date: 12 May 91 23:10:36 GMT References: <1991May10.064610.25802@starnet.uucp> <1991May12.022641.18961@mp.cs.niu.edu> Organization: University of Auckland, New Zealand. Lines: 31 rickert@mp.cs.niu.edu (Neil Rickert) writes: >In article <1991May10.064610.25802@starnet.uucp> moe@starnet.uucp (Moe S.) writes: >>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 >> 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.