{"id":188,"date":"2011-02-12T11:29:02","date_gmt":"2011-02-12T03:29:02","guid":{"rendered":"http:\/\/ykyi.net\/?p=188"},"modified":"2011-02-12T11:29:02","modified_gmt":"2011-02-12T03:29:02","slug":"diff-patch-and-friendsdiff-patch%e5%92%8c%e4%bb%96%e4%bb%ac%e7%9a%84%e7%9b%b8%e5%85%b3%e5%b7%a5%e5%85%b7%e7%ac%ac%e4%b8%80%e7%af%87","status":"publish","type":"post","link":"https:\/\/ykyi.net\/?p=188","title":{"rendered":"Diff, Patch, and Friends(diff, patch\u548c\u4ed6\u4eec\u7684\u76f8\u5173\u5de5\u5177)(\u7b2c\u4e00\u7bc7)"},"content":{"rendered":"<p>\u539f\u6587 http:\/\/www.linuxjournal.com\/article\/1237<br \/>\n\t\u7ffb\u8bd1: ykyi.net<\/p>\n<p>&ldquo;Kernel patches&rdquo; may sound like magic, but the two tools used to create and apply patches are simple and easy to use&mdash;if they weren&#39;t, some Linux developers would be too lazy to use them&#8230;<br \/>\n\t&quot;\u5185\u6838\u8865\u4e01&quot;\u542c\u8d77\u6765\u76f8\u5f53\u4e4b\u795e\u5947\uff0c\u4f46\u662f\u6709\u4e24\u4e2a\u7528\u6765\u521b\u5efa\u8865\u4e01\u548c\u5e94\u7528\u8865\u4e01\u7684\u5de5\u5177\u5374\u7b80\u5355\u6613\u7528\u3002\u5982\u679c\u5b83\u4eec\u5f88\u96be\u7528\u7684\u8bdd\uff0c\u4e00\u4e9bLinux\u5f00\u53d1\u8005\u624d\u61d2\u5f97\u7528\u5b83\u4eec\u5462\u3002<\/p>\n<p>Diff is designed to show you the differences between files, line by line. It is fundamentally simple to use, but takes a little practice. Don&#39;t let the length of this article scare you; you can get some use out of diff by reading only the first page or two. The rest of the article is for those who aren&#39;t satisfied with very basic uses.<br \/>\n\tdiff\u8fd9\u4e2a\u5de5\u5177\u8bbe\u8ba1\u6210\u53ef\u4ee5\u5411\u4f60\u5c55\u793a\u6587\u4ef6\u4e4b\u95f4\u884c\u4e0e\u884c\u7684\u533a\u522b\u3002\u5b83\u4f7f\u7528\u8d77\u6765\u662f\u76f8\u5f53\u7684\u7b80\u5355\uff0c\u4f46\u9700\u8981\u4e00\u70b9\u7ec3\u4e60\u624d\u4e60\u3002\u4f60\u5343\u4e07\u4e0d\u8981\u8ba9\u957f\u957f\u7684\u4ecb\u7ecd\u6587\u6863\u628a\u4f60\u5413\u4f4f\u3002\u4f60\u53ef\u4ee5\u5148\u53ea\u8bfb\u524d\u4e00\u4e24\u9875\u6587\u6863\uff0c\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u4f7f\u7528diff\u6765\u5f00\u5c55\u4e00\u4e9b\u5de5\u4f5c\u4e86\u3002\u4f59\u4e0b\u7684diff\u4ecb\u7ecd\u6587\u6863\u662f\u5199\u7ed9\u90a3\u4e9b\u5bf9\u57fa\u672c\u7528\u6cd5\u975e\u5e38\u4e0d\u6ee1\u7684\u5947\u5f02\u4eba\u58eb\u7684\u3002 http:\/\/ykyi.net<\/p>\n<p>While diff is often used by developers to show differences between different versions of a file of source code, it is useful for far more than source code. For example, diff comes in handy when editing a document which is passed back and forth between multiple people, perhaps via e-mail. At Linux Journal, we have experience with this. Often both the editor and an author are working on an article at the same time, and we need to make sure that each (correct) change made by each person makes its way into the final version of the article being edited. The changes can be found by looking at the differences between two files.<br \/>\n\tdiff\u88ab\u5f00\u53d1\u8005\u7528\u6765\u540c\u4e00\u4e2a\u6e90\u6587\u4ef6\u7684\u6bd4\u8f83\u4e0d\u540c\u7248\u672c\u4e4b\u95f4\u7684\u533a\u522b\u3002\u8fd9\u8fd8\u53ef\u4ee5\u6709\u5f88\u591a\u5176\u5b83\u7684\u7528\u9014\u3002\u6bd4\u5982\uff0c\u5f53\u7f16\u8f91\u4e00\u4e2a\u5728\u5f88\u591a\u4eba\u4e4b\u95f4\u901a\u8fc7email\u4f20\u9012\u7684\u6587\u6863\u65f6\uff0cdiff\u5de5\u5177\u975e\u5e38\u65b9\u4fbf\u3002\u5728Linux Journal\u7f51\u7ad9\uff0c\u6211\u4eec\u7ecf\u5386\u8fc7\u8fd9\u4e9b\u3002\u7f16\u8f91\u548c\u4f5c\u8005\u540c\u65f6\u4fee\u6539\u540c\u4e00\u4e2a\u6587\u7ae0\u7684\u60c5\u51b5\u975e\u5e38\u5e38 \u89c1\uff0c\u6211\u4eec\u9700\u8981\u786e\u4fdd\u6bcf\u4e2a\u4eba\u6240\u4f5c\u7684\u4fee\u6539\u90fd\u88ab\u6b63\u786e\u5e94\u7528\u5230\u8fd9\u7bc7\u6587\u7ae0\u7684\u6b63\u786e\u4f4d\u7f6e\u3002\u88ab\u4fee\u6539\u7684\u90e8\u5206\u53ef\u4ee5\u901a\u8fc7\u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u7684\u533a\u522b\u5f97\u5230\u3002<\/p>\n<p>However, it is hard to show off how helpful diff can be in finding these kinds of differences. To demonstrate with files large enough to really show off diff&#39;s capabilities would require that we devote the entire magazine to this one article. Instead, because few of our readers are likely to be fluent in Latin, at least compared to those fluent in English, we will give a Latin example from Winnie Ille Pu, a translation by Alexander Leonard of A. A. Milne&#39;s Winnie The Pooh (ISBN 0-525-48335-7). This will make it harder for the average reader to see differences at a glance and show how useful these tools can be in finding changes in much larger documents.<br \/>\n\t\u4f46\u662f\uff0c\u8981\u8ba9\u4f60\u6e05\u695a\u7684\u77e5\u9053diff\u5de5\u5177\u5728\u67e5\u627e\u6587\u4ef6\u4e4b\u95f4\u7684\u533a\u522b\u65b9\u9762\u662f\u591a\u4e48\u6709\u7528\u662f\u7528\u70b9\u96be\u5ea6\u7684\u3002\u8981\u5411\u4f60\u6e05\u695a\u5c55\u793adiff\u7684\u6240\u6709\u6240\u6709\u529f\u80fd\uff0c\u9700\u8981\u6574\u4e2aLinux Journal\u6742\u5fd7\u8fd9\u4e48\u5927\u7684\u7bc7\u5e45\u6765\u4ecb\u7ecd(zausiu: \u8fd9\u53e5\u8bdd\u6211\u4e0d\u592a\u786e\u5b9a\u6709\u6ca1\u6709\u8bd1\u5bf9)\u3002\u6211\u4e0d\u8fd9\u6837\u505a\uff0c\u7531\u4e8e\u6bd4\u8f83\u5c11\u4e00\u90e8\u5206\u4eba\u53ef\u4ee5\u6d41\u5229\u8bfb\u61c2\u62c9\u4e01\u6587\uff0c\u81f3\u5c11\u540c\u80fd\u591f\u8bfb\u82f1\u6587\u7684\u4eba\u6570\u76f8\u6bd4\u53ef\u4ee5\u8bfb\u62c9\u4e01\u6587\u7684\u662f\u5c11\u6570\u6d3e\uff0c\u6211\u7ed9\u51fa\u4e00\u4e2a\u7528\u62c9\u4e01\u6587\u7684\u4f8b\u5b50\u3002\u8fd9\u6837\u4e00\u6765\uff0c\u4e00\u822c\u4eba\u5c31\u4e0d\u592a\u80fd\u4e00\u773c\u770b\u51fa\u4e0d\u540c\u4e4b\u5904\u6765\uff0c\u4f60\u5c31\u80fd\u591f\u7406\u89e3diff\u7528\u6765\u67e5\u627e\u5927\u6587\u4ef6\u4e4b\u95f4\u7684\u533a\u95f4\u662f\u591a\u4e48\u6709\u7528\u4e86\u3002http:\/\/ykyi.net<\/p>\n<p>Quickly now, find the differences between these two passages:<br \/>\n\t\u5e9f\u8bdd\u5c11\u8bf4\uff0c\u627e\u627e\u4e0b\u9762\u4e24\u6bb5\u8bdd\u7684\u533a\u522b\uff1a<\/p>\n<p>Ecce Eduardus Ursus scalis nunc tump-tump-tump<br \/>\n\toccipite gradus pulsante post Christophorum<br \/>\n\tRobinum descendens. Est quod sciat unus et solus<br \/>\n\tmodus gradibus desendendi, non nunquam autem<br \/>\n\tsentit, etiam alterum modum exstare, dummodo<br \/>\n\tpulsationibus desinere et de no modo meditari<br \/>\n\tpossit. Deinde censet alios modos non esse. En,<br \/>\n\tnunc ipse in imo est, vobis ostentari paratus.<br \/>\n\tWinnie ille Pu.<\/p>\n<p>Ecce Eduardus Ursus scalis nunc tump-tump-tump<br \/>\n\toccipite gradus pulsante post Christophorum<br \/>\n\tRobinum descendens. Est quod sciat unus et solus<br \/>\n\tmodus gradibus descendendi, nonnunquam autem<br \/>\n\tsentit, etiam alterum modum exstare, dummodo<br \/>\n\tpulsationibus desinere et de eo modo meditari<br \/>\n\tpossit. Deinde censet alios modos non esse. En,<br \/>\n\tnunc ipse in imo est, vobis ostentari paratus.<br \/>\n\tWinnie ille Pu.<\/p>\n<p>You may be able to find one or two changes after some careful comparison, but are you sure you have found every change? Probably not: tedious, character-by-character comparison of two files should be the computer&#39;s job, not yours.<br \/>\n\t\u5982\u679c\u4f60\u4ed4\u4ed4\u7ec6\u7ec6\uff0c\u8ba4\u8ba4\u771f\u771f\u5730\u6bd4\u8f83\uff0c\u4f60\u80fd\u591f\u53d1\u73b0\u4e00\u5230\u4e24\u4e2a\u4e0d\u540c\u4e4b\u5904\u3002\u4f46\u662f\u4f60\u53ef\u4ee5\u4fdd\u8bc1\u4f60\u627e\u5230\u4e86\u6240\u6709\u7684\u4e0d\u540c\u4e4b\u5904\u4e86\u5417\uff1f\u4e0d\uff01\u9010\u5b57\u7684\u6bd4\u8f83\u6587\u4ef6\u4e4b\u95f4\u7684\u4e0d\u540c\u662f\u7535\u8111\u7684\u4e13\u957f\uff0c\u800c\u4e0d\u662f\u4f60\uff0d\uff0dhumanbeing !&nbsp;<\/p>\n<p>\u8bf7\u770b\u7b2c\u4e8c\u7bc7\u3002<\/p>\n<p>copyright ykyi.net<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587 http:\/\/www.linuxjournal.com\/article\/1237 \u7ffb\u8bd1: ykyi.net &ldquo;Kernel patches&rdquo; may sound like magic, but the two tools used to create and apply patches are simple and easy to use&mdash;if they weren&#39;t, some Linux developers would be too lazy to use them&#8230; &quot;\u5185\u6838\u8865\u4e01&quot;\u542c\u8d77\u6765\u76f8\u5f53\u4e4b\u795e\u5947\uff0c\u4f46\u662f\u6709\u4e24\u4e2a\u7528\u6765\u521b\u5efa\u8865\u4e01\u548c\u5e94\u7528\u8865\u4e01\u7684\u5de5\u5177\u5374\u7b80\u5355\u6613\u7528\u3002\u5982\u679c\u5b83\u4eec\u5f88\u96be\u7528\u7684\u8bdd\uff0c\u4e00\u4e9bLinux\u5f00\u53d1\u8005\u624d\u61d2\u5f97\u7528\u5b83\u4eec\u5462\u3002 Diff is designed to show you the differences between files, line by line. It is fundamentally &hellip; <a href=\"https:\/\/ykyi.net\/?p=188\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Diff, Patch, and Friends(diff, patch\u548c\u4ed6\u4eec\u7684\u76f8\u5173\u5de5\u5177)(\u7b2c\u4e00\u7bc7)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[28,83],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-tech_articles","category-unix_linux","tag-diff","tag-unix-tools"],"_links":{"self":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":0,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"wp:attachment":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}