View source for Minmax
Jump to:
navigation
,
search
This is a draft. You've caught this content before I had a chance to format it. Get the Min, Max, Median, and Average of a set of numbers... I really only needed the min and max. I Googled, and found there wasn't something in the distro that could do this right off the bat. To same myself, and possibly you, time in your moment of need, here are the best solutions I found. If you find something more elegant, please email me at my callsign via ARRL dot net. USING AWK #!/bin/sh sort -n | awk ' BEGIN { c = 0; sum = 0; } $1 ~ /^[0-9]*(\.[0-9]*)?$/ { a[c++] = $1; sum += $1; } END { ave = sum / c; if( (c % 2) == 1 ) { median = a[ int(c/2) ]; } else { median = ( a[c/2] + a[c/2-1] ) / 2; } OFS="\t"; print sum, c, ave, median, a[0], a[c-1]; } The above I consider a quick-and-dirty solution. There is an impressively wide array of solutions here: http://unix.stackexchange.com/questions/13731/is-there-a-way-to-get-the-min-max-median-and-average-of-a-list-of-numbers-in
Return to
Minmax
.
Navigation menu
Personal tools
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
Actions
Search
Navigation
Main page
Community portal
Current events
Recent changes
Random page
Help
Toolbox
What links here
Related changes
Special pages
Page information