From owner-freebsd-questions@FreeBSD.ORG Fri Aug 22 12:26:20 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 9B2581065681 for ; Fri, 22 Aug 2008 12:26:20 +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 E00008FC1E for ; Fri, 22 Aug 2008 12:26:19 +0000 (UTC) (envelope-from steve@ibctech.ca) Received: (qmail 59310 invoked by uid 89); 22 Aug 2008 12:33:55 -0000 Received: from unknown (HELO ?IPv6:2607:f118::5?) (steve@ibctech.ca@2607:f118::5) by 2607:f118::b6 with ESMTPA; 22 Aug 2008 12:33:55 -0000 Message-ID: <48AEB0C6.9030301@ibctech.ca> Date: Fri, 22 Aug 2008 08:27:50 -0400 From: Steve Bertrand User-Agent: Thunderbird 2.0.0.16 (Windows/20080708) MIME-Version: 1.0 To: freebsd-questions@FreeBSD.ORG, walt@wump.org, steve@ibctech.ca References: <200808220759.m7M7xuh0047625@lurza.secnetix.de> In-Reply-To: <200808220759.m7M7xuh0047625@lurza.secnetix.de> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: 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: Fri, 22 Aug 2008 12:26:20 -0000 Oliver Fromme wrote: > Walt Pawley wrote: > > I guess getting old, nearly blind and mind numbing close to > > brain dead is better than the alternative. Try this (sooner or > > later I've got to get it right)... > > > > perl -pe 's/(.*?)\.(.*)\t.*/$1_$2\@example.com/' input_file > output_file > > > I think your attempts show very well why Steve wanted to > avoid perl. :-) LOL...actually, I use Perl for almost everything, but I don't think I've ever used it on the command line. For things that I need to do on a repeated basis where most of the variables are consistent, or for automation tasks I always use Perl. > - tr, sed, awk etc. are part of the FreeBSD base system, > while perl is not. This is another reason. I do have a couple of machines that do not have Perl installed on them, so when I need to do a quick change to multiple entries in a file, I'm quite used to using sed/awk. It had just been a while since I've used it to make more than one change per entry (well, since my tcpdump file example). Oliver posted yesterday three examples using sed, awk and tr. The one that I will stick with and will not have any difficulty remembering was this one: # tr '.\t' '_@' | sed 's/@.*/@example.com/' I am the most familiar with that one as I use sed on almost an every day basis. I appreciate all of the feedback. There have been some excellent methods that have been very wide ranging. As the saying goes, TIMTOWTDI ;) Steve