I have a series piped greps, awks and seds which produce a list of numbers, one on each line. Something like this:

1.13
3.59 
1.23

How can i pipe this to something which will output the average, max, and min?

link|improve this question

80% accept rate
If you're piping grep, awk and sed together, the same thing can often be done in one invocation of awk. – Dennis Williamson Feb 23 '11 at 23:54
feedback

2 Answers

up vote 6 down vote accepted

Since you're already using awk

blahblahblah | awk '{if(min==""){min=max=$1}; if($1>max) {max=$1}; if($1<min) {min=$1}; total+=$1; count+=1} END {print total/count, max, min}'
link|improve this answer
Nice, it works for me! – JavaRocky Feb 23 '11 at 23:44
I thought there would of been already a binary which accepts a list of numbers and the count, avg, min, max for you, kind of like using 'time'. – JavaRocky Feb 23 '11 at 23:45
feedback

I find this program useful for generating stats on lists of numbers at the command line: http://web.cs.wpi.edu/~claypool/misc/stats/stats.html

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.