From owner-freebsd-questions@FreeBSD.ORG Thu Aug 21 13:10:22 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04C4610656A0 for ; Thu, 21 Aug 2008 13:10:22 +0000 (UTC) (envelope-from steve@ibctech.ca) Received: from ibctech.ca (v6.ibctech.ca [IPv6:2607:f118::b6]) by mx1.freebsd.org (Postfix) with SMTP id 90B958FC30 for ; Thu, 21 Aug 2008 13:10:21 +0000 (UTC) (envelope-from steve@ibctech.ca) Received: (qmail 14100 invoked by uid 89); 21 Aug 2008 13:17:51 -0000 Received: from unknown (HELO ?IPv6:2607:f118::5?) (steve@ibctech.ca@2607:f118::5) by 2607:f118::b6 with ESMTPA; 21 Aug 2008 13:17:51 -0000 Message-ID: <48AD6996.8040502@ibctech.ca> Date: Thu, 21 Aug 2008 09:11:50 -0400 From: Steve Bertrand User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: Matthias Apitz References: <48AD63B7.8090107@ibctech.ca> <20080821055429.A26910@eskimo.com> <20080821130154.GA11071@rebelion.Sisis.de> In-Reply-To: <20080821130154.GA11071@rebelion.Sisis.de> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: Joseph Olatt , freebsd-questions@freebsd.org Subject: Re: sed/awk, instead of Perl X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 13:10:22 -0000 Matthias Apitz wrote: > El día Thursday, August 21, 2008 a las 05:54:29AM -0700, Joseph Olatt escribió: > >> 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: >> john.doe example.com > > Despite of the magic awk(1) or while-loops: this is all UUOC Award; > http://en.wikipedia.org/wiki/Cat_(Unix)#Useless_use_of_cat Yeah, yeah :) I know that: # grep username /var/log/radius.log ...is much, much better than: # cat /var/log/radius.log | grep username ...but that is just semantics, relative to the intent and purpose of this excercise. Besides, our mail servers don't do enough work, so using cat in the wrong context when modifying tens of thousands of lines in a file is good exercise for my boxes ;) Steve