![搜索日志以查找唯一的电子邮件地址](https://linux22.com/image/629303/%E6%90%9C%E7%B4%A2%E6%97%A5%E5%BF%97%E4%BB%A5%E6%9F%A5%E6%89%BE%E5%94%AF%E4%B8%80%E7%9A%84%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6%E5%9C%B0%E5%9D%80.png)
我想搜索我的日志文件并仅显示以“邮件表格:”开头的唯一电子邮件地址
例如,如果我搜索,可能会得到以下结果:
Mon 2014-03-17 00:01:38: <-- MAIL FROM:<[email protected]>
Mon 2014-03-17 00:01:38: [email protected] is an alias for [email protected]
Mon 2014-03-17 00:01:38: --> 250 <[email protected]>, Sender ok
Mon 2014-03-17 00:01:38: <-- RCPT TO:<[email protected]>
Mon 2014-03-17 00:01:38: --> 250 <[email protected]>, Recipient ok
Mon 2014-03-17 00:01:38: <-- RCPT TO:<[email protected]>
Mon 2014-03-17 00:01:38: --> 250 <[email protected]>, Recipient ok
Mon 2014-03-17 00:01:39: <-- MAIL FROM:<[email protected]>
Mon 2014-03-17 00:01:39: [email protected] is an alias for [email protected]
Mon 2014-03-17 00:01:39: --> 250 <[email protected]>, Sender ok
Mon 2014-03-17 00:01:39: <-- RCPT TO:<[email protected]>
Mon 2014-03-17 00:01:39: --> 250 <[email protected]>, Recipient ok
Mon 2014-03-17 00:01:39: <-- RCPT TO:<[email protected]>
Mon 2014-03-17 00:01:39: --> 250 <[email protected]>, Recipient ok
两个都[电子邮件保护]和[电子邮件保护]该文件中可能有数百个条目。
您能推荐一个 Widnows 上用于此目的的简单工具吗?
答案1
sed -e 's/\(^.*<\)\(.*\)\(>.*$\)/\2/' yourfile.txt | sort |uniq
这是 unix 示例,但你可以获取适用于 Windows 命令行的实用程序
sed http://gnuwin32.sourceforge.net/packages/sed.htm
排序和唯一 http://gnuwin32.sourceforge.net/packages/coreutils.htm
答案2
就我个人而言,我很喜欢强力Grep来自 JGSoft(我是用户,没有附属关系)。您可以选择将相同匹配分组。您可以下载试用版,但我认为它物有所值。