for awk experts only.

Polytropon freebsd at edvax.de
Sat Nov 29 21:11:08 PST 2008


Good morning!

On Sat, 29 Nov 2008 20:59:51 -0800, Gary Kline <kline at 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, ...


More information about the freebsd-questions mailing list