Skip to content

Instantly share code, notes, and snippets.

@obfusk
Created November 18, 2013 21:33
Show Gist options
  • Save obfusk/7535719 to your computer and use it in GitHub Desktop.
Save obfusk/7535719 to your computer and use it in GitHub Desktop.
random line w/ ruby
ruby -e 'puts STDIN.lines.with_index.reduce(nil) { |x,(l,i)| rand(i+1) < 1 ? l : x }' <<< $'foo\nbar\nbaz'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment