On Sat, 29 Nov 2008 20:59:51 -0800, Gary Kline <[EMAIL PROTECTED]> 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);}}'
>       If there are any shortcuts, please clue me in!

Don't do this with a long stream of if/else/.../else blocks.  AWK is a
pattern based rule-language.  You can apply different blocks of code to
lines that match patterns like this:

    $3 ~ /adjective/ { print $1,"adj." }
    $3 ~ /noun/      { print $1,"n." }
    $3 ~ /verb/      { print $1,"v." }

freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to