Date: Thu, 21 Aug 2008 12:52:07 -0400 From: Gerard <gerard@seibercom.net> To: freebsd-questions@freebsd.org Subject: OT: Re: sed/awk, instead of Perl Message-ID: <20080821125207.2ba8ef66@scorpio> In-Reply-To: <200808211349.m7LDnHHX000891@lurza.secnetix.de> References: <48AD63B7.8090107@ibctech.ca> <200808211349.m7LDnHHX000891@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Thu, 21 Aug 2008 15:49:17 +0200 (CEST)
Oliver Fromme <olli@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@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@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
>cat(1).
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
ago.
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
gerard@seibercom.net
Technological progress has merely provided us
with more efficient means for going backwards.
Aldous Huxley
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (FreeBSD)
iEYEARECAAYFAkitnTgACgkQ6DWTaTcTwMn43gCgyF5VqUGvfSgUYPwiUJOYn3vk
2MQAni1BoaNziKhIvUouhX6QafSTY3tB
=hBUD
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080821125207.2ba8ef66>
