Lably
Skip to content

File comparison

Diff and merge files on computers

  • 2 min read
  • 4 chapters

Related on Lably

Through Computing, Text file and Graphical user interface

The methods, implementations, and results are typically called a diff, after the Unix diff utility. The output may be presented in a graphical user interface or used as part of larger tasks in networks, file systems, or revision control.

Some widely used file comparison programs are diff, cmp, FileMerge, WinMerge, Beyond Compare, and File Compare.

Many text editors and word processors perform file comparison to highlight the changes to a file or document.

Method types

Most file comparison tools find the longest common subsequence between two files. Any data not in the longest common subsequence is presented as a change or an insertion or a deletion.

In 1978, Paul Heckel published an algorithm that identifies most moved blocks of text. This is used in the IBM History Flow tool. Other file comparison programs find block moves.

Some specialized file comparison tools find the longest increasing subsequence between two files. The rsync protocol uses a rolling hash function to compare two files on two distant computers with low communication overhead.

File comparison in word processors is typically at the word level, while comparison in most programming tools is at the line level. Byte or character-level comparison is useful in some specialized applications.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication