From: Joshua Abbott Date: 2008-12-10T05:51:18+09:00 Subject: Re: compare 2 text files - check for difference - Please hel Are you wanting to get the actual differences, or just know if they are different? -- Josh http://iammrjoshua.com Mmcolli00 Mom wrote: > require 'diff/lcs/Array' > > file = File.open("1.txt",'r') > @row = {} > file.each_line do |@line| > key, val = @line.chomp.split(",",0) > @row[key] = val > end > > file2 = File.open("2.txt",'r') > @row2 = {} > file2.each_line do |@line2| > key2, val2 = @line2.chomp.split(",",0) > @row2[key2] = val2 > end > > > puts diffs = Diff::LCS.diff(@line,@line2) > > testing files contents... > 1.txt 2.txt > 1,2 1,2,3 > > outputed when files different as above: > # > # > # > > outputed when files are identicial > # > > I want to be able to say that 2.txt contained '3' therefore the file was > not the same on that line. Thanks. MC -- Posted via http://www.ruby-forum.com/.