From owner-freebsd-questions@FreeBSD.ORG Sun Nov 30 05:11:08 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 9B887106564A for ; Sun, 30 Nov 2008 05:11:08 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de (mx01.qsc.de [213.148.129.14]) by mx1.freebsd.org (Postfix) with ESMTP id 651858FC1E for ; Sun, 30 Nov 2008 05:11:08 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r55.edvax.de (port-92-196-24-200.dynamic.qsc.de [92.196.24.200]) by mx01.qsc.de (Postfix) with ESMTP id 8C92E3CAFE; Sun, 30 Nov 2008 06:11:06 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id mAU5B4r4001847; Sun, 30 Nov 2008 06:11:04 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Sun, 30 Nov 2008 06:11:04 +0100 From: Polytropon To: Gary Kline Message-Id: <20081130061104.f595db7e.freebsd@edvax.de> In-Reply-To: <20081130045944.GA94896@thought.org> References: <20081130045944.GA94896@thought.org> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: FreeBSD Mailing List Subject: Re: for awk experts only. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 30 Nov 2008 05:11:08 -0000 Good morning! On Sat, 29 Nov 2008 20:59:51 -0800, Gary Kline wrote: > wordnet/wn prints the string "noun" out whereas I'd rather it simply > printed "n." Is there a way of making this substitution using awk? > (I've never used awk except as a cmdline filter.) > > The following fails: > > wn foot -over |grep Overview |awk > {if(!strcmp($3,"noun"))$3="n."; '{printf("%s %s\n", $4, $3);}}' Of course. You cannot have $3 as a lvalue (read: You cannot change its value). > If there are any shortcuts, please clue me in! Don't make it more complicated than it is. :-) % wn foot -over | grep "Overview" | awk \ '{ printf("%s %s\n", $4, gsub("noun", "n.", $3)); }' And the more I think about it, the more I believe there are much easier ways to do this. But I'm sure the magic of how it works just opened up to you. Sidenote: I wouldn't consider myself as an AWK expert allthough I did abuse AWK lately to implement a stastistical evaluation program for blood sugar data into a PDF file with diagrams a CVS file, involving gnuplot and \LaTeX{}. =^_^= -- Polytropon >From Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...