I have two big files (6GB each). They are unsorted, with linefeeds (
\n) as separators. How can I diff them? It should take under 24h.
The most obvious answer is just to use the diff command and it is probably a good idea to add the --speed-large-files parameter to it.
diff --speed-large-files a.file b.file
You mention unsorted files so maybe you need to sort the files first
sort a.file > a.file.sorted sort b.file > b.file.sorted diff --speed-large-files a.file.sorted b.file.sorted
you could save creating an extra output file by piping the 2nd sort output direct into diff
sort a.file > a.file.sorted sort b.file | diff --speed-large-files a.file.sorted -
Obviously these will run best on a system with plenty of available memory and you will likely need plenty of free disk space too.
It wasn't clear from your question whether you have tried these before. If so then it would be helpful to know what went wrong (took too long etc.). I have always found that the stock sort and diff commands tend to do at least as well as custom commands unless there are some very domain specific properties of the files that make it possible to do things differently.