perl -lane 'if($.==1){@a=@F[2..(scalar(@F)-1)] }else{@a = map { $a[$_] + $F[$_+2] } 0..$#a;}END{for($i=0;$i<scalar(@a);$i++ ){print "Test".($i+1).":".$a[$i]/$.}}'
a b 10 1000 100 a b 10 1000 100 a b 10 1000 100 a b 10 1000 100
Test1:10 Test2:1000 Test3:100
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!