Created
August 8, 2009 13:26
-
-
Save bakkdoor/164413 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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