I have 5 files file1.txt file2.txt....file5.txt, then I have a list of 3 wordsred white blue
I am trying to figure out how many times and in which files red white blue.
Finally, the format should be:
red = file1.txt, file3.txt, 2
white = file2.txt, 1
blue = file1.txt, file2.txt, file3.txt, 3
This is what I have so far:
files.each do |i|
curfile = File.new("#{i}","r")
while (line = curfile.gets)
mywords.each do |j|
if (line ~= /\b#{j}\b/)
end
end
end
end
What data structure should I put in the results?
source
share