From: Paul Lutus Date: 2006-12-02T14:35:12+09:00 Subject: Re: [OT] calculations on lists of numbers ara.t.howard@noaa.gov wrote: > > for years i've felt that i should be able to pipe numerical output into > some unix command like so > > cat list | mean > cat list | sum > cat list | minmax > > etc. > > and have never found one. right now i'm building a ruby version - before > i continue, does anyone know a standard unix or ruby version of this? It is so easy to create in Ruby, a matter of minutes, that it is not terribly important to do the search you are suggesting. -------------------------------- #!/usr/bin/ruby -w array = [] STDIN.read.split(/\s+/).each do |item| if(v = item.to_f) array << v end end if(array.size > 0) sum = 0 array.each { |v| sum += v } mean = sum / array.size puts sum.to_s + " " + mean.to_s + " " + array.min.to_s + " " + array.max.to_s end -------------------------------- $ echo 1 2 3 4 5 | (script_name) Output: 15.0 3.0 1.0 5.0 -- Paul Lutus http://www.arachnoid.com