sed/awk, instead of Perl

Joseph Olatt joji at
Thu Aug 21 12:54:31 UTC 2008

On Thu, Aug 21, 2008 at 08:46:47AM -0400, Steve Bertrand wrote:
> I'm frequently having to modify/convert email addresses from one 
> format/domain to another.
> Usually, I slap together a quick Perl script to do this for me. I don't 
> do it frequently enough to keep track which one of my scripts does this 
> for me, so I'm continuously re-inventing the wheel.
> Some of the time, I use sed/awk to do this, but that usually requires a 
> few passes over a few files.
> To put it plainly, can anyone, if it's possible, provide a single line 
> sed/awk pipeline that can:
> - read email addresses from a file in the format:
> TAB domain.tld
> - convert it to:
> user_name at
> - write it back to either a new file, the original file, or to STDOUT
> Regards,
> Steve

Try the following:

 cat t.txt | awk -F\t '{split($1, arr, "."); printf("%s_%s@%s\n", arr[
1], arr[2], $2);}'

where t.txt:


More information about the freebsd-questions mailing list