Portal Home > Knowledgebase > Articles Database > how to... get only emails from exim.log?
how to... get only emails from exim.log?
Posted by papajo, 04-16-2008, 05:19 PM |
Hello, I need to analize exim.log and I have to 'cut' ONLY emails, I`ve got for example
2008-04-13 04:02:16 1JkpDm-0007aN-V6 == lukasz412@o2.ps R=lookuphost T=remote_smtp defer (-53): retry time not reached for any host
I think I should use 'cut' command but I don`t really know how to use it, could somebody help me? I want add that it is exim.log with many lines, I want grep only emails. Thanks in advance!
Last edited by papajo; 04-16-2008 at 05:32 PM.
|
Posted by scamp81, 04-16-2008, 06:10 PM |
You could use this perl script. Just create the script chmod +x it and change the path referenced by $file to the path to your file. It will list emails 1 per line
#!/usr/bin/perl
$file="your path";
@emails;
open(MYF,"$file");
while(){
$line=$_;
chomp $line;
if($line=~/(\w+\@\w+\.\w{2,4})\s+/){
push(@emails,$1);
}
$line="";
}
foreach $item (@emails){
print $item."\n";
}
|
Posted by papajo, 04-16-2008, 06:15 PM |
Thanks I also used cut -d ' ' -f5 and it works also, thanks again!
Hmm works different, I will analyze perl
// edit
yeah cut command also get error messages with grep @ works fine.
Last edited by papajo; 04-16-2008 at 06:19 PM.
|
Add to Favourites Print this Article
Also Read