patch < diff
To create a patch, one could run the following command in a shell:
$ diff -u oldFile newFile > mods.diff # -u tells diff to output unified diff format
diff的原理是什么?即LCS(Longest Common Subsequence,最长公共自序列)算法,复杂度为o(M*N)(m=line of oldFile,n=line of newFile,将每一行看作一个序列的一个元素)
To apply a patch, one could run the following command in a shell:
$ patch < mods.diff
Patches can be undone, or reversed, with the '-R' option:
$ patch -R < mods.diff
抄了wiki这么多,其实是想说"unified diff format"。首先是中文翻译,什么“统一输出格式”,“统一区别格式”,我觉得都不好,在我自作主张给他取名字之前,先看看它的一个通俗解释。
再抄一段,算了,请移步:http://www.blogjava.net/ivanwan/archive/2005/08/04/9261.html
故我称之为“UFO”,即Unified diFf fOrmat 。
浙公网安备 33010602011771号