Using sed
:
$ sed 's/@\(.*\)/&|\1/' file
TEST|1234|john.doe@gmail.com|gmail.com
TEST|4533|jeffp12@yahoo.com|yahoo.com
TEST|9030|indoep13@gmx.com|gmx.com
TEST|0903|ramdpe23@gmail.com|gmail.com
This would match the first @
character on each line and capture everything after it with a capture group. The matched text would be replaced by itself followed by the captured text, with a |
character in-between.
If your file is a DOS text file (as indicated by some of the comments), then you can handle the conversion to a Unix text file in one and the same command:
$ sed -e 's/[[:cntrl:]]$//' -e 's/@\(.*\)/&|\1/' file
TEST|1234|john.doe@gmail.com|gmail.com
TEST|4533|jeffp12@yahoo.com|yahoo.com
TEST|9030|indoep13@gmx.com|gmx.com
TEST|0903|ramdpe23@gmail.com|gmail.com
The 2nd substitution is the same as before, but the first will remove any control character at the very end of the line (this would remove a carriage return character at the end of each line, if there was one). The output of this last command will be a Unix text document regardless of whether the original file was a DOS or Unix text file.