awk script to solve this problem

March 10, 2011 at 03:37:25
Specs: Linux i686
sir,
i have 3 files and it contains time n packets sent column.i want to add the number of packet sent every 10 sec by add the no of packets sent from each of the file and storing it in the 4th file..
file 1
10.017465 0.519030
20.050239 0.422148
30.076594 0.393353
40.125853 0.369653
50.140395 0.355016
60.147553 0.348256
70.158063 0.341232
80.161470 0.338425
90.166674 0.334071

file 2
10.027610 0.038996
20.524566 0.049626
30.709619 0.050840
41.667591 0.049884
51.802014 0.051257
61.858991 0.053205
71.873950 0.053578
82.805427 0.051318
92.836983 0.051802

file 3
10.094696 0.043730
20.103688 0.148080
30.176981 0.147265
40.386365 0.139643
50.421648 0.142291
60.502656 0.136663
70.600363 0.139338
80.626817 0.142099
90.641572 0.145858
plz help...


See More: awk script to solve this problem

Report •

#1
March 10, 2011 at 09:36:13
Your files have 2 columns. I don't know which column is to be added, so this script adds up both:

#!/bin/ksh

awk ' BEGIN { totcol1=totcol2=0 }
{
   totcol1+=$1
   totcol2+=$2
}
END { printf("%s %s\n", totcol1, totcol2)
}
' file1 file2 file3 > myoutput.txt


Report •
Related Solutions


Ask Question