<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://jackxiang.com/post//</link>
<title><![CDATA[diff详解,读懂diff结果，主要用它打patch，因为现在都是在Linux上运行在wijdows上diff居多了。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Unix/LinuxC技术]]></category>
<pubDate>Tue, 23 Aug 2016 23:52:47 +0000</pubDate> 
<guid>http://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	一般都要sort排序一下后再比对为好：<br/>sort eee.txt &gt; eeee.txt<br/>sort fff.txt &gt; ffff.txt<br/>diff -c eeee.txt ffff.txt<br/>——————————————————<br/><br/>抄来抄去，直接看这篇文章得了：<br/>http://blog.chinaunix.net/uid-26000296-id-3507646.html<br/><br/>这儿注意大于小于的含义：<br/>diff&nbsp;&nbsp;cccc.txt dddd.txt <br/>19a20<br/>&gt; 999 备注：大于是指左边文件没有右边有。<br/>而用-c提示相比上面这种方法更直观一些：<br/>diff -c&nbsp;&nbsp;cccc.txt dddd.txt <br/>*** cccc.txt&nbsp;&nbsp;&nbsp;&nbsp;2016-12-02 16:00:25.378913370 +0800<br/>--- dddd.txt&nbsp;&nbsp;&nbsp;&nbsp;2016-12-02 16:00:58.528306679 +0800<br/>***************<br/>*** 17,19 ****<br/>--- 17,20 ----<br/>&nbsp;&nbsp;10.71.182.93<br/>&nbsp;&nbsp;10.71.182.96<br/>&nbsp;&nbsp;10.71.182.99<br/>+ 999<br/><br/><br/>注意：改变位置会在其前面三行和后面三行，因此一共显示7行。<br/>文件内容的每一行最前面，还有一个标记位。如果为空，表示该行无变化；如果是感叹号（!），表示该行有改动；如果是减号（-），表示该行被删除；如果是加号（+），表示该行为新增。<br/>=====================================<br/><br/>假设有两个文件：<br/><br/>//file1.txt<br/><br/>I need to buy apples.<br/><br/>I need to run the laundry.<br/><br/>I need to wash the dog.<br/><br/>I need to get the car detailed.<br/><br/>//file2.txt<br/><br/>I need to buy apples.<br/><br/>I need to do the laundry.<br/><br/>I need to wash the car.<br/><br/>I need to get the dog detailed.<br/><br/>我们使用diff比较他们的不同：diff file1.txt file2.txt<br/><br/><br/>2,4c2,4 前面的数字2,4表示第一个文件中的行，中间有一个字母c表示需要在第一个文件上做的操作(a=add,c=change,d=delete)，后面的数字2,4表示第二个文件中的行。<br/><br/>2,4c2,4 的含义是：第一个文件中的第[2,4]行(注意这是一个闭合区间，包括第2行和第4行)需要做出修改才能与第二个文件中的[2,4]行相匹配。接下来的内容则告诉我们需要修改的地方，前面带 &lt; 的部分表示左边文件的第[2,4]行的内容，而带&gt; 的部分表示右边文件的第[2,4]行的内容，中间的 --- 则是两个文件内容的分隔符号。<br/><br/>打patch的比较最常用：<br/>-e 将比较的结果保存成一个ed脚本，之后ed程序可以执行该脚本文件，从而将file1修改成与file2一样的文字内容:<br/>[root@iZ25dcp92ckZ diff]# diff -e 1.txt 2.txt &gt; script.txt<br/>diff: 1.txt: 没有那个文件或目录<br/>diff: 2.txt: 没有那个文件或目录<br/>[root@iZ25dcp92ckZ diff]# diff -e file1.txt file2.txt &gt; script.txt<br/>[root@iZ25dcp92ckZ diff]# cat script.txt<br/>7c<br/>I need to get the dog detailed.<br/>.<br/>5c<br/>I need to wash the car.<br/>.<br/>3c<br/>I need to do the laundry.<br/>.<br/>1c<br/> need to buy apples.<br/>.<br/>[root@iZ25dcp92ckZ diff]#<br/><br/>这样就是生成了一个ed可以执行的脚本文件script.txt，生成脚本文件之后我们还需要做一个操作， 在脚本文件末尾添加ed的write指令，只需要执行 echo &quot;w&quot; &gt;&gt;script.txt 将w指令附加到脚本文件的最后一行即可。<br/><br/>那么如何应用该脚本文件呢，可以这样使用：<br/><br/>ed - file1.txt &lt; script.txt<br/><br/>注意中间的 – 符号表示从标准输入中读取，而 &lt; script.txt 则重定向script.txt的内容到标准输入。这样执行之后1.txt的内容将与2.txt完全相同。<br/><br/>[root@iZ25dcp92ckZ ~]# cd /tmp/diff<br/>[root@iZ25dcp92ckZ diff]#&nbsp;&nbsp;echo &quot;w&quot; &gt;&gt;script.txt<br/>[root@iZ25dcp92ckZ diff]# ed - file1.txt &lt; script.txt<br/>[root@iZ25dcp92ckZ diff]# diff file1.txt file2.txt<br/>[root@iZ25dcp92ckZ diff]#<br/><br/>比对发现一样，得证。<br/>来自:<br/>【diff详解,读懂diff结果】<br/>http://m.pstatp.com/group/6321440713972171010/?iid=5181229840&amp;app=news_article&amp;tt_from=android_share&amp;utm_medium=toutiao_android&amp;utm_campaign=client_share<br/><br/>
]]>
</description>
</item><item>
<link>http://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] diff详解,读懂diff结果，主要用它打patch，因为现在都是在Linux上运行在wijdows上diff居多了。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>