Linux/Unix – Comparing and patching a file with a difference report.
There are a number of tools for comparing the contents of files in different ways; these recipes show how to use some of them. These tools are especially useful for comparing passages of text in files, but that’s not the only way you can use them.
Patching a File with a Difference Report
To apply the differences in a difference report to the original file compared in the report, use patch. It takes as arguments the name of the file to be patched and the name of the difference report file (or “patchfile”). It then applies the changes specified in the patchfile to the original file. This is especially useful for distributing different versions of a file−−small patchfiles may be sent across networks easier than large source files.
To update the original file `manuscript.new’ with the patchfile `manuscript.diff’, type:
$ patch manuscript.new manuscript.diff