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
--Sig_/eC+DiSxLuv0dhvGpUehkgT2 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable 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: > >=20 > > - read email addresses from a file in the format: > >=20 > > user.name TAB domain.tld > >=20 > > - convert it to: > >=20 > > user_name@example.com =20 > >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. --=20 Gerard gerard@seibercom.net Technological progress has merely provided us with more efficient means for going backwards. Aldous Huxley --Sig_/eC+DiSxLuv0dhvGpUehkgT2 Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (FreeBSD) iEYEARECAAYFAkitnTgACgkQ6DWTaTcTwMn43gCgyF5VqUGvfSgUYPwiUJOYn3vk 2MQAni1BoaNziKhIvUouhX6QafSTY3tB =hBUD -----END PGP SIGNATURE----- --Sig_/eC+DiSxLuv0dhvGpUehkgT2--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080821125207.2ba8ef66>