I have two text files, master.txt and 926.txt. If there is a line in 926.txt that is not in master.txt, I want to write to a new file, notinbook.txt.
I wrote the best thing I could think of, but given that I'm a terrible/newbie programmer it failed. Here's what I have
g = File.new("notinbook.txt", "w")
File.open("926.txt", "r") do |f|
while (line = f.gets)
x = line.chomp
if
File.open("master.txt","w") do |h|
end
while (line = h.gets)
if line.chomp != x
puts line
end
end
end
end
end
g.close
Of course, it fails. Thanks!
This should work:
This was my test:
926.txt
master.txt
notinbook.txt
You can do something like this:
Hope this helps
Use : http://raa.ruby-lang.org/project/compare/
OR
%x(diff file1 file2)
OR
http://github.com/myobie/htmldiff/