Date: Sun, 30 Nov 2008 06:11:04 +0100 From: Polytropon <freebsd@edvax.de> To: Gary Kline <kline@thought.org> Cc: FreeBSD Mailing List <freebsd-questions@freebsd.org> Subject: Re: for awk experts only. Message-ID: <20081130061104.f595db7e.freebsd@edvax.de> In-Reply-To: <20081130045944.GA94896@thought.org> References: <20081130045944.GA94896@thought.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Good morning!
On Sat, 29 Nov 2008 20:59:51 -0800, Gary Kline <kline@thought.org> 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, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081130061104.f595db7e.freebsd>
