I know this question has been put before, but in a more simplistic way, like averaging $1 every 5 rows.
I would like to know how to average out a column when $1 has the same number ( but there is not equal amounts of numbers in $1). e.g.
635 -1.47 0 62.125 8.835 7.365 5.5
635 -1.97 1.91877 69.575 8.835 6.865 4.3
635 -2.47 3.91275 70.75 8.835 6.365 8.5
635 -2.97 1.23997 69.175 8.835 5.865 5.6
636 -1.47 0 60.725 8.71 7.24 10.8
636 -1.97 0 64.2 8.71 6.74 15.3
636 -2.47 0.2642 68.6 8.71 6.24 8.5
637 -1.47 0 60.95 8.96 7.49 8.4
637 -1.97 0 62.575 8.96 6.99 5.3
638........
while $1 = 635, average out $7
output:
635 -1.47 0 62.125 8.835 7.365 5.5 5.975 (average printed as $8)
635 -1.97 1.91877 69.575 8.835 6.865 4.3 5.975
635 -2.47 3.91275 70.75 8.835 6.365 8.5 5.975
635 -2.97 1.23997 69.175 8.835 5.865 5.6 5.975
636 -1.47 0 60.725 8.71 7.24 10.8 11.53
636 -1.97 0 64.2 8.71 6.74 15.3 11.53
where i am really struggling is the part of: 'if/while $1 = $1, then do'
because $1 is always going to equal $1!
argh!
thanks
I would like to know how to average out a column when $1 has the same number ( but there is not equal amounts of numbers in $1). e.g.
635 -1.47 0 62.125 8.835 7.365 5.5
635 -1.97 1.91877 69.575 8.835 6.865 4.3
635 -2.47 3.91275 70.75 8.835 6.365 8.5
635 -2.97 1.23997 69.175 8.835 5.865 5.6
636 -1.47 0 60.725 8.71 7.24 10.8
636 -1.97 0 64.2 8.71 6.74 15.3
636 -2.47 0.2642 68.6 8.71 6.24 8.5
637 -1.47 0 60.95 8.96 7.49 8.4
637 -1.97 0 62.575 8.96 6.99 5.3
638........
while $1 = 635, average out $7
output:
635 -1.47 0 62.125 8.835 7.365 5.5 5.975 (average printed as $8)
635 -1.97 1.91877 69.575 8.835 6.865 4.3 5.975
635 -2.47 3.91275 70.75 8.835 6.365 8.5 5.975
635 -2.97 1.23997 69.175 8.835 5.865 5.6 5.975
636 -1.47 0 60.725 8.71 7.24 10.8 11.53
636 -1.97 0 64.2 8.71 6.74 15.3 11.53
where i am really struggling is the part of: 'if/while $1 = $1, then do'
because $1 is always going to equal $1!
argh!
thanks