Sed command to reformat mangled email address

Here are some mangled email address:

[email protected]
[email protected]
[email protected]

I need to reformat order the emails to the right form like:

[email protected]
[email protected]
[email protected]

How can I reformate order the emails to the right form using Linux and sed command?

An email consists of three parts: username, domain name and TLDs. All these three parts are grabbed as substring and in the replacement string, they are placed in the order.

$sed 's/\(..*\)@\(..*\)\.\(..*\)/\2@\3.\1/'

Recommended Posts