Command-Line Diff – Handling Lines Out of Order

command linediff()

I want to diff two sets of mod_rewrite rules. The set of lines are about 90% identical, but the order is so different that diff basically says they are completely different.

How can I see which lines are truly different between two files, regardless of their line number?

Best Answer

sort can be used to get the files into the same order so diff can compare them and identify the differences. If you have process substitution, you can use that and avoid creating new sorted files.

diff <(sort file1) <(sort file2)