OT: Re: sed/awk, instead of Perl

Gerard gerard at seibercom.net
Thu Aug 21 16:52:15 UTC 2008

On Thu, 21 Aug 2008 15:49:17 +0200 (CEST)
Oliver Fromme <olli at lurza.secnetix.de> wrote:

> > 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:
> > 
> > user.name TAB domain.tld
> > 
> > - convert it to:
> > 
> > user_name at example.com  
>With awk(1):
>    awk '{sub(/\./, "_", $1); print $1 "@example.com"}'
>With sed(1) (you have to replace "^T" with a real tab!):
>    sed 's/^\(.*\)\.\(.*\)^T.*/\1_\2 at example.com/'
>With tr(1) + sed(1):
>    tr '.\t' '_@' | sed 's/@.*/@example.com/'
>Personally I like the last solution best, because it's
>short and easy to understand.
>BTW, all of the above command read from stdin and write
>to stdout, so you can use shell redirection to read from
>a file and/or write to a file.  There is no need to use

It seems like we have all had fun picking on the use of 'cat'. I would
like to close this discussion with something I learned in school long

A big cat is a Lion, and a Lion is a dangerous animal. However, a
little cat is a pussy, and a little pussy never hurt anyone.

gerard at seibercom.net

Technological progress has merely provided us
with more efficient means for going backwards.

	Aldous Huxley
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080821/89d6f8de/signature.pgp

More information about the freebsd-questions mailing list