使用grep查找所有电子邮件 [英] Using grep to find all emails
本文介绍了使用grep查找所有电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何正确构建greplinux程序的正则表达式,找到所有电子邮件,比如说/ etc目录?
目前,我的脚本如下:
grep -srhw[[:alnum:]] * @ [[ :alnum:]] */ etc
工作正常 - 查看一些电子邮件,但当我修改它时,要在@符号之前和之后捕捉一个或多个字符...
grep -srhw [[:alnum:]] + @ [[:alnum:]] +/ etc
它完全停止工作
另外,它不会捕获形式为Name.LastName@site.com的电子邮件。
帮助!
解决方案
以下是另一个例子
grep -Eiorh'([[:alnum:] _.-] + @ [[:alnum:] _.-] +?\。[[:alpha :]。] {2,6})'$ @* |排序| uniq> emails.txt
此变体适用于3个级别的域。
How to properly construct regular expression for "grep" linux program, to find all email in, say /etc directory ? Currently, my script is following:
grep -srhw "[[:alnum:]]*@[[:alnum:]]*" /etc
It working OK - a see some of the emails, but when i modify it, to catch the one-or-more charactes before- and after the "@" sign ...
grep -srhw "[[:alnum:]]+@[[:alnum:]]+" /etc
.. it stops working at all
Also, it does't catches emails of form "Name.LastName@site.com"
Help !
解决方案
Here is another example
grep -Eiorh '([[:alnum:]_.-]+@[[:alnum:]_.-]+?\.[[:alpha:].]{2,6})' "$@" * | sort | uniq > emails.txt
This variant works with 3 level domains.
这篇关于使用grep查找所有电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文