Results 1 to 5 of 5
Hi everyone,
I'm trying to extract the domain name from an SMTP log for bad domains...
All the @ symbols are messing up anything I try.
File sample (domains edited):
...
- 09-29-2008 #1Just Joined!
- Join Date
- Sep 2008
- Posts
- 2
need help using grep / sed / awk to extract domain
Hi everyone,
I'm trying to extract the domain name from an SMTP log for bad domains...
All the @ symbols are messing up anything I try.
File sample (domains edited):
@blah.com@0@MailGroup@rr7@21@0@0.00@@421
@blah2.com@0@MailGroup@rr10@21@0@0.00@@421
@blah3.net@0@MailGroup@rr2@21@0@9.00@@421
@blah4.com@0@MailGroup@rr8@21@0@5.00@@421
@blah5.com@0@MailGroup@rr12@21@0@11.00@@421
@blah6.com@0@MailGroup@rr10@21@0@11.00@@421
My last thought was to try pulling based on the .com/.net/.cc/.biz/etc but I can only get it to return the last 4 characters...
Thanks for the help
- 09-30-2008 #2Just Joined!
- Join Date
- Jun 2008
- Posts
- 10
Well, this isn't sed or awk, but would the Cut command work for you?
Generates:Code:cut -d "@" -f2 smptlogfile
Code:blah.com blah2.com blah3.net blah4.com blah5.com blah6.com
- 09-30-2008 #3Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
Try awk
awk -F '@' '{print $2}' smptlogfile
- 09-30-2008 #4Linux User
- Join Date
- Aug 2006
- Posts
- 458
if you have PHP
Code:<?php $filename="file"; if ( $handle = fopen($filename,"r") ){ while( ( $data = fgetcsv($handle,0,"@")) !==FALSE ){ echo "domain:$data[1]\n"; } } fclose($handle); ?>
- 09-30-2008 #5Just Joined!
- Join Date
- Sep 2008
- Posts
- 2
Thanks ghostdog, secondmouse, and thinkwell.
All 3 work perfectly.


Reply With Quote