Skip to content

Instantly share code, notes, and snippets.

@meetupwayne
Created August 23, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meetupwayne/4f1d5a6298224761367955e486db0e09 to your computer and use it in GitHub Desktop.
Save meetupwayne/4f1d5a6298224761367955e486db0e09 to your computer and use it in GitHub Desktop.
print ("Enter file name: ")
fname = gets.strip()
fname = "mbox-short.txt" if (fname.length < 1)
fh = open(fname)
count = 0
fh.readlines.each do |line|
if line.start_with?('From') and not line.start_with?('From:') then
puts line.split()[1]
count+= 1
end
end
puts("There were, #{count}, lines in the file with From as the first word")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment