Fun CLI Ruby

Seems ruby follows perl/awk in many ways especially arguments.

Print file name for files over 1k bytes .. obviously can do with find .. but you might want to slice/dice fields or do more with contents, etc.

$ ls -l | ruby -ane '$F[0]["d"] or ($F[4].to_i > 1000 and puts $F[-1])'  

Datascience – Ruby

Just having a play with ruby and thought I’d try to simulate summary(x):

irb(main):001:0> y=[]
irb(main):002:0> def x();rand(9999);end;
=> :x
irb(main):003:0> def summary(x=0); puts "min: #{x.min} max: #{x.max} mean: #{(x.sum(0.0)/x.size).round(2)}"; end
=> :summary
irb(main):004:0> 99.times do; y<<x;end
=> 99
irb(main):005:0> summary(y)
min: 23 max: 9851 mean: 5127.23