David Resnick wrote:

[...]

>
> How about something like this?  Or did you want gawk instead
> of perl for some reason?

I'm not (and assume will not be) a programmer but try hard to solve
problems with scripts if it's necessary and I'm interested in Perl
because of its capacity (especially ability to connect to MySQL) and
"elegance".

First of all I try to get quick ;-) and simple solutions with the tools
I already know better than Perl (in this case gawk)

[...]


Here are my 2 little gawk-scripts that bring me ahead:

1. get a count per line

BEGIN { FS = OFS = "\t" }

      { cnt = 0
              for ( i = 3; i <= NF; i++ )
                      if ( $i == 214 || $i == 220 || $i == 223 || $i == 214 
||228 $i
== 240 || $i == 252 ) {
                              cnt++
                         }
        print $1, $2, cnt
      }


(BTW: I think your PERL-script disregards that a record can have a
varying number of fields)


2. sum up for the groups


BEGIN   { FS = OFS = "\t" }
        { cntansi[$1"\t"$2] += $3 }
END     { for (grosso in cntansi)
                print grosso, cntansi[grosso]
        }

Thanks for your idea and

greetings
Oliver Peters

_______________________________________________
help-gnu-utils mailing list
[EMAIL PROTECTED]
http://lists.gnu.org/mailman/listinfo/help-gnu-utils

Reply via email to