How to Delete lines that contain more than three dots in a email before @ character using SED?

Posted on

Problem :

sed '/(.*..*){4,}/d'

The above command mentioned recognizes every DOT in the line…

It is recognizing DOTS after @ sign too.
For example, even this is shown in the result: ryisan@Sariyer.Cc.itu.Edu.tr

Can you help me modify the above command in such a way that only the LEFT side of @ it counts the Multiple DOTS more than 3 and ignores the DOTS after the character @ to right side of the email?

Eg:

fgtc21_pk@yahoo.com
bhchemitex@chemitex.com
hjcindysun48@hotmail.com
hhconsult_sa.jan.2020@yahoo.com
s.ing.song.lan.g.ju.n.55.l@gmail.com
VB.t.o.t.all.y.f.it.s.19.99@yahoo.com
a.lice.i.n.wonde.r.lnd.2.1.f@dkg.com
ryisan@Sariyer.Cc.itu.Edu.tr

I want the following lines with multiple Dots (3 or more dots) at the LEFT SIDE of @ Character to be only recognizers and deleted from the file.

s.ing.song.lan.g.ju.n.55.l@gmail.com
VB.t.o.t.all.y.f.it.s.19.99@yahoo.com
a.lice.i.n.wonde.r.lnd.2.1.f@dkg.com

Any experts, plz suggest me how to modify the above SED command…. Thanks

Solution :

I’m not an expert but, to delete only the 4 dots (or more) patterns at the left side of @ you can simply add @.* at the end of your expression:

sed '/(.*..*){4,}@.*/d'

It means to delete the 4 dots (or more) patterns at the left side of the @ regardless what characters are at the right side.

Leave a Reply

Your email address will not be published. Required fields are marked *