Ubuntu 16.04
GNU bash,4.4.0版
我需要提取一个文件中的电子邮件,该文件以单词abuse开头。下面是一个文件,其中包含了ip地址的whois信息,其中包含了电子邮件abuse@web.ad.jp。
% [whois.apnic.net]
% Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
% Information related to '121.92.0.0 - 121.93.255.255'
% Abuse contact for '121.92.0.0 - 121.93.255.255' is 'hostmaster@nic.ad.jp'
inetnum: 121.92.0.0 - 121.93.255.255
netname: InfoWeb
descr: FUJITSU LIMITED
descr: 17-25, SHINKAMATA 1-CHOME, OTA-KU,
descr: TOKYO 144-8588, JAPAN
country: JP
admin-c: JNIC1-AP
tech-c: JNIC1-AP
status: ALLOCATED PORTABLE
remarks: Email address for spam or abuse complaints abuse@web.ad.jp
mnt-by: MAINT-JPNIC
mnt-irt: IRT-JPNIC-JP
mnt-lower: MAINT-JPNIC
last-modified: 2015-12-01T22:23:26Z
source: APNIC
irt: IRT-JPNIC-JP
address: Urbannet-Kanda Bldg 4F, 3-6-2 Uchi-Kanda
address: Chiyoda-ku, Tokyo 101-0047, Japan
e-mail: hostmaster@nic.ad.jp
abuse-mailbox: hostmaster@nic.ad.jp
admin-c: JNIC1-AP
tech-c: JNIC1-AP
auth: # Filtered
mnt-by: MAINT-JPNIC
last-modified: 2017-10-18T10:21:54Z
source: APNIC我不关心哪个命令从文件中提取abuse@web.ad.jp的电子邮件地址,我只关心它是否有效。
在过去,我曾使用grep查找文件中的所有电子邮件地址,如.
grep -o '[[:alnum:]+\.\_\-]*@[[:alnum:]+\.\_\-]*' "$1" | sort | uniq -i
但绝不是以单词开头的电子邮件,所以命令的预期输出会给我带来abuse@web.ad.jp.
发布于 2018-08-30 07:56:39
$ grep "abuse[a-z]*@[a-z\.]\+" -o <filename>假设你的电子邮件不包括数字或大写字母。
https://stackoverflow.com/questions/52091763
复制相似问题