perl -lan -e 'BEGIN{$sum=0;$num = 0}' -e '$sum += $F[0]; $num++; END{$avg=$sum/$num;print "avg:$avg"}' data.dat
to find the average of the first column in a file
Wednesday, July 20, 2005
Subscribe to:
Posts (Atom)
This is not really a blog, I just paste some random stuffs like , my common coding errors, LaTeX tips I come across etc etc .