user9@totl.example.com>, size=35020827, class=-30, nrcpts=1, msgid=<2m96JLQblfm/fh.01u3YnFYK0bc3pmOExg2vA.totl.example.com>, proto=ESMTP, daemon=MTA-v6, relay=lemur.totl.example.com
user11@shoe-bags.example.com>, size=18071179, class=-30, nrcpts=1, msgid=<BhaYKoWuhDhrUQcT5.+tF6eKTCu0459KjSflNxLg.shoe-bags.example.com>, proto=ESMTP, daemon=MTA-v6, relay=dog.shoe-bags.example.com
user23@stellar-patrol.example.com>, size=27057917, class=-30, nrcpts=1, msgid=<VaD1xW8SduAYImck.Mbx1MBcKTjBPlQpcaDhJRA.stellar-patrol.example.com>, proto=ESMTP, daemon=MTA-v6, relay=feinstein.stellar-patrol.example.com
user6@planet-express.example.com>, size=15212380, class=-30, nrcpts=1, msgid=<4wN8i90XT.BIdywWoKxNjeEM1q.planet-express.example.com>, proto=ESMTP, daemon=MTA-v6, relay=fry.planet-express.example.com
user19@blackmesa.example.com>, size=44656174, class=-30, nrcpts=1, msgid=<1froj29vndf7h0.Qzoi+1hDEQOVp1frnQvWO.blackmesa.example.com>, proto=ESMTP, daemon=MTA-v6, relay=barney.blackmesa.example.com
user2@stellar-patrol.example.com>, size=4556372, class=-30, nrcpts=1, msgid=<jnugzy+Z.L82rx1mhoSXi0RmK/yNP.stellar-patrol.example.com>, proto=ESMTP, daemon=MTA-v6, relay=feinstein.stellar-patrol.example.com
user7@macrohard.example.com>, size=35391498, class=-30, nrcpts=1, msgid=<fXr7+HM1U7ZpbJqxf.iJs6q9r.macrohard.example.com>, proto=ESMTP, daemon=MTA-v6, relay=corporate-mail-01.macrohard.example.com
user7@lawanda.example.com>, size=46296174, class=-30, nrcpts=1, msgid=<UJHE3Y4uEn.JBT3RESrNYL+fH5dFTGt5A.lawanda.example.com>, proto=ESMTP, daemon=MTA-v6, relay=achilles.lawanda.example.com
user14@feddit.example.com>, size=12197030, class=-30, nrcpts=1, msgid=<gpq6lYSHHC67d.ZjyKUitfcPwOlA/OEc++.feddit.example.com>, proto=ESMTP, daemon=MTA-v6, relay=kittin.feddit.example.com
我希望只提取每行的电子邮件地址部分,例如 user9@tot1.example.com
我目前正在使用这种技术:
cat file | grep -o 'user.*?com'
但是,由于“.com”有时位于行尾,因此我还是会以某种方式返回整行。
我的示例输出应类似于:
user9@totl.example.com
user11@shoe-bags.example.com
user23@stellar-patrol.example.com
... etc
这怎么可能?非常感谢您的帮助