From: Guillaume Bloss Date: 2011-10-05T21:34:40+09:00 Subject: Best way to compare lines in 2 files Hi everybody, I have an issue : I have 2 list in 2 separate files I call them 1st file = old file, 2nd file = new file They are similar, except there is some lines added and some lines removed in both files, and I only want to keep : lines common in both files and line only existing in my 2nd file. My first solution is to read the 2nd file, compare each lines with each lines of the 1st file see if I fond it and if not, save it in a 3rd file to list all lines I have to remove in my 2nd file. Then I will read my 2nd file and compare each line with each lines of my 3rd file, if it does not exist, I write the line in a 4th file (the final) I'm not sure if this is the quickest and best method, maybe something faster exist. I also assume there is a fast method, with high memory usage and a slower but with low memory usage. My files are excel sheet exported in CSV files, but with something like 40k lines each So if someone have clues to help me I would be grateful. -- Posted via http://www.ruby-forum.com/.