diff is a Unix command-line tool that compares two text files and reports what would have to change to turn one into the other. The 7th Edition Unix manual page describes its job plainly: diff “tells what lines must be changed in two files to bring them into agreement.” Its output is a compact list of additions, deletions, and changes keyed to line numbers, rather than the two whole files printed side by side.
The tool grew out of work at Bell Labs in the 1970s. The 1976 Bell Laboratories technical report “An Algorithm for Differential File Comparison,” by James W. Hunt and M. Douglas McIlroy, set out the method behind it: finding a longest common subsequence of lines shared by both files, so that everything outside that common part is reported as inserted or deleted. The report describes the algorithm that the Unix diff command used.
Because its output can be read by both people and programs, diff became a building block rather than a standalone curiosity. Early versions could emit an “ed script,” a set of editor commands that mechanically transform the first file into the second, as noted in the 7th Edition manual page. That machine-readable form is what later allowed differences to be saved, mailed, and re-applied automatically.
This combination of compactness and reproducibility made diff the basis of patching and, eventually, of version control. Recording only what changed, instead of full copies, is the idea that lets a project store its entire history efficiently and lets many people share edits to the same files.