Jan 23 00:46:24 portal postfix/smtp[31481]: 1B1653FEA1: to=<[email protected]>,relay=mta5.am0.yahoodns.net[98.138.112.35]:25,delay=5.4,delays=0.02/3.2/0.97/1.1,dsn=5.0.0,status=bounced (host mta5.am0.yahoodns.net[98.138.112.35] saID: 554 delivery error: dd This user doesn't have a yahoo.com account ([email protected]) [0] - mta1321.mail.ne1.yahoo.com (in reply to end of DATA command))Jan 23 00:46:24 portal postfix/smtp[31539]: AF40C3FE99: to=<[email protected]>,relay=mta7.am0.yahoodns.net[98.136.217.202]:25,delay=5.9,delays=0.01/3.1/0.99/1.8,status=bounced (host mta7.am0.yahoodns.net[98.136.217.202] saID: 554 delivery error: dd This user doesn't have a yahoo.com account ([email protected]) [0] - mta1397.mail.gq1.yahoo.com (in reply to end of DATA command))
从上面的maillog我想提取括号之间的电子邮件地址< ...>例如.到= LT; [email protected]\u0026gt;想要[email protected]
我正在使用cut -d” – f7来提取电子邮件,但我很好奇是否有更灵活的方式.
解决方法 使用GNU grep,只需使用包含外观的正则表达式并向前看:$grep -Po '(?<=to=<).*(?=>)' [email protected][email protected]
这说:嘿,提取前面的所有字符串to =<然后是>.
总结以上是内存溢出为你收集整理的regex – 使用grep或sed从日志中提取电子邮件地址全部内容,希望文章能够帮你解决regex – 使用grep或sed从日志中提取电子邮件地址所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)