Skip to content

Instantly share code, notes, and snippets.

@colinsurprenant
Created April 13, 2011 17:17
Show Gist options
  • Save colinsurprenant/917939 to your computer and use it in GitHub Desktop.
Save colinsurprenant/917939 to your computer and use it in GitHub Desktop.
ruby unix style pipe/filter example
require 'rubygems'
require 'benchmark'
line_count = 0
elapsed = Benchmark.realtime do
while (line = $stdin.gets)
puts(line)
line_count += 1
end
$stdin.close
end
$stderr.puts("processed #{line_count} lines in #{"%.2f" % elapsed}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment