+ -
当前位置:首页 → 问答吧 → 文本过滤

文本过滤

时间:2011-02-23

来源:互联网

  1. Feb 23 00:00:20 spam-gateway postfix/cleanup[22162]: 2796A51C952: hold: header Received: from mta.neco.com (unknown [212.167.24.29])??by out.mta.neco.com (Postfix) with ESMTP id 2796A51C952;??Wed, 23 Feb 2011 00:00:20 +0800 (HKT) from unknown[212.167.24.29]; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mta.neco.com>
  2. Feb 23 00:00:22 spam-gateway postfix/cleanup[22162]: 9797951C952: hold: header Received: from mta.neco.com (unknown [212.167.24.29])??by out.mta.neco.com (Postfix) with ESMTP id 9797951C952??for <[email protected]>; Wed, 23 Feb 2011 00:00:22 +0800 (HKT) from unknown[212.167.24.29]; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mta.neco.com>
  3. Feb 23 00:00:27 spam-gateway postfix/cleanup[22162]: 0EEF351C952: hold: header Received: from mta.neco.com (unknown [212.167.24.29])??by out.mta.neco.com (Postfix) with ESMTP id 0EEF351C952??for <[email protected]>; Wed, 23 Feb 2011 00:00:27 +0800 (HK from unknown[212.167.24.29]; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mta.neco.com>
复制代码
如上内容,请问如何把to=<*>和from=<*>中的域名过滤出来?

作者: netocool   发布时间: 2011-02-23

本帖最后由 yinyuemi 于 2011-02-23 10:52 编辑

awk '{print $2}' RS="from=<|to=<" FS="@|>"
luto.com.cn
luto.com.cn
googlegroups.com
gotu.com
ccitane.com
longtim.com

作者: yinyuemi   发布时间: 2011-02-23

[99superman@ubuntu test]$perl -nle 'print $1,"-->",$2 if /from=\<.*?\@(.*?)\>\s+to=\<.*?\@(.*?)\>/' file         
luto.com.cn-->luto.com.cn
googlegroups.com-->gotu.com
ccitane.com-->longtim.com

作者: 99超人   发布时间: 2011-02-23

grep -oP '(?<=from=<|to=<).*?(?=>)' file

作者: ziyunfei   发布时间: 2011-02-23

域名还是email啊

作者: ziyunfei   发布时间: 2011-02-23

域名

作者: netocool   发布时间: 2011-02-23

本帖最后由 netocool 于 2011-02-23 10:54 编辑


QUOTE:
grep -oP '(?
ziyunfei 发表于 2011-02-23 10:40




请问如何统计出前10最多的from和前10最多的to的域名,并且计算出数量呢?

作者: netocool   发布时间: 2011-02-23

本帖最后由 yinyuemi 于 2011-02-23 11:08 编辑

回复 netocool
  1. awk 'NR!=1&&NR%2{to[$2]++}(NR-1)%2{from[$2]++} END{for(i in from) {print "form",from[i],i|"sort -k2nr|head -10"} for(j in to) {print "to",to[j],j|"sort -nr |head -10"}}' RS="from=<|to=<" FS="@|>"
复制代码

作者: yinyuemi   发布时间: 2011-02-23

热门下载

更多