Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created August 8, 2009 13:26
Show Gist options
  • Save bakkdoor/164413 to your computer and use it in GitHub Desktop.
Save bakkdoor/164413 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
filename = ARGV.size > 0 ? ARGV[0] : nil
unless filename
puts "usage: one_word_per_line.rb <filename>"
exit 0
end
File.open filename do |f|
f.readlines.each do |line|
line.split(/\s+/).reject{|w| w.empty?}.each do |word|
puts word
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment