Hi This part of the description of task is unclear "first line of each of the five groups". To what 5 groups do you refer ? Simply after putting the lines in a file called dat.txt get started by pulling the columns using auto split switch -a.
perl -ane '{print $F[5]," ",$F[6],"\n";}' < dat.txt -135.185 178.150 -49.668 -31.158 ... snip -81.417 52.986 -83.126 -56.051
Now do a simple ave
perl -ane '{$t5+=$F[5]; $t6+=$F[6]; $t+=1} END{print $t5/$t," ",$t6/$t,"\n";}' < dat.txt -85.6206666666667 30.2721333333333
Just guessing what is meant by "5 groups". This example uses the contents of Field 3 ( counting from 0 ) to do the grouping
perl -ane '{$t5{$F[3]}+=$F[5]; $t6{$F[3]}+=$F[6]; $t{$F[3]}+=1} END{foreach $i (keys %t5) {print "Group $i ",$t5{$i}/$t{$i}," ",$t6{$i +}/$t{$i},"\n";}} ' < dat.txt Group S -75.969 10.2868 Group G -108.8372 73.3412 Group M -72.0558 7.1884

In reply to Re: averaging a group of lines with numeric value in a text file by gannett
in thread averaging a group of lines with numeric value in a text file by Anas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.