Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting e-mail address from output file

Status
Not open for further replies.

gcazian

MIS
Dec 4, 2002
61
US
I have an output file that contains one very large string, and looks look this:

<who><presence from='username1@myserver.mydomain.com/Exodus' to='username2@myserver.mydomain.com'>

followed by some more non-important data. I want to extract the first e-mail address using sed or awk.

I'm a bit of a novice, so any help would be greatly appreciated.
 
Try this awk program

BEGIN {FS=&quot;'&quot;}
{
sub (/\/.*$/,&quot;&quot;,$2)
print $2
}


CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
<who><presence from='username1@myserver.mydomain.com/Exodus' to='username2@myserver.mydomain.com'>
With sed, you can try this:
Code:
sed -n &quot;/from=/s!.*from='\([^']*\)'.*!\1!p&quot; /path/to/file

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top