From: Jon Hawkins Date: 2007-08-13T06:00:13+09:00 Subject: stdin stdout -ing my program i need to be able to run my program fully from the command line, instead of 'ruby program.rb'....i need to pipe the commands using standard input and output. How would i do this with the code below? Code: require 'find' Dir.chdir("/") res = [] Find.find("/") {|path| res << File.size( path).to_f if File.file?( path)} puts "Total Number of Files: #{res.length}" puts "Average File Size: #{res.inject(0) {|sum, i| sum + i}/res.length/1024} Kilobytes" puts "Max File Size: #{res.max/1024}KB" puts "Min File Size: #{res.min}KB" puts "================================" puts "================================" res.delete_if {|b| b < 1} puts "Weighted Average: #{res.inject(0) {|sum, i| sum + i}/res.length/1024} Kilobytes" # Lol Standard Deviation def mean(res) res.inject(0) {|sum, x| sum += x} / res.size.to_f / 1024 end def mean_and_standard_deviation(res) m = mean(res) variance = res.inject(0) {|variance, x| variance += (x - m) ** 2} Math.sqrt(variance/(res.size - 1)) / 1024 end puts "Standard Deviation = #{mean_and_standard_deviation(res)}" ############## So how would i pipe find from a shell command? Thanks, -Jon -- Posted via http://www.ruby-forum.com/.