- publishing free software manuals
Comparing and Merging Files with GNU diff and patch
by David MacKenzie, Paul Eggert, and Richard Stallman
Paperback (6"x9"), 120 pages
ISBN 0954161750
RRP £12.95 ($19.95)

"Well packaged... the quality of information is excellent" --- Linux User and Developer Magazine (Issue 36, Feb 2004) Get a printed copy>>>

2.5.1 ed Scripts

diff can produce commands that direct the ed text editor to change the first file into the second file. Long ago, this was the only output mode that was suitable for editing one file into another automatically; today, with patch, it is almost obsolete. Use the -e or --ed option to select this output format.

Like the normal format (see section 2.2 Showing Differences Without Context), this output format does not show any context; unlike the normal format, it does not include the information necessary to apply the diff in reverse (to produce the first file if all you have is the second file and the diff).

If the file ‘d’ contains the output of ‘diff -e old new’, then the command ‘(cat d && echo w) | ed - old’ edits ‘old’ to make it a copy of ‘new’. More generally, if ‘d1’, ‘d2’, ..., ‘dN’ contain the outputs of ‘diff -e old new1’, ‘diff -e new1 new2’, ..., ‘diff -e newN-1 newN’, respectively, then the command ‘(cat d1 d2 ... dN && echo w) | ed - old’ edits ‘old’ to make it a copy of ‘newN’.

ISBN 0954161750Comparing and Merging Files with GNU diff and patchSee the print edition