问题
I have some original data that I do not want to reference, but I do want to be able to patch. If I use diff -u on a file where I entirely replaced its contents with something else, instead of getting basically a 'delete all' plus all the new lines, I get the whole old file with '-' before each line.
We can assume the original data doesn't change for the moment. Is there a way to get diff to make a patch without duplicating any of the original data with '-' lines, i.e., have it just describe line numbers to delete along the way, and then all the insertions?
回答1:
Use the -e
option for both diff
and patch
, instead of -u
.
来源:https://stackoverflow.com/questions/25569575/excluding-deleted-lines-from-diff-output