免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 884 | 回复: 0
打印 上一主题 下一主题

diff & patch [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-12-26 15:06 |只看该作者 |倒序浏览

                               
Comparing and Merging Files
1. diff
%和空格有关的选项
  • -E:忽略因把制表符扩展为空格而造成的差异
  • -b:忽略因空白符的数目而造成的差异
  • -w:忽略所有空白符
  • -B:忽略空行(指连空白符都没有的行)
%忽略大小写: -i
%忽略所有差异都匹配正则表达式的行: -I regexp
%只列出哪些文件互不相同: -q
%输入格式
  • without context
change-command
to-file-line
> to-file-line...
change-command可以是:(lar,Add the lines in range r of the second file after
line l of the first file.或fct,Replace the lines in range f of the first
file with lines in range t of the second file.或rdl,Delete the lines in
range r from the first file; line l is where they would have appeared
in the second file had they not been deleted)
  • with context
选项:-C num 或 -c
输出格式:
*** from-file from-file-modification-time--- to-file to-file-modification time****************** from-file-line-range ****  from-file-line  from-file-line...--- to-file-line-range ----  to-file-line  to-file-line...
上下文以两个空格开始,不同的同以+,-,或!及后跟一个空格开始
!
    A line that is part of a
group of one or more lines that changed between the two files. There is
a corresponding group of lines marked with ! in the part of this hunk
for the other file.
+
    An "inserted" line in the second file that corresponds to nothing in the first file.
-
    A "deleted" line in the first file that corresponds to nothing in the second file.
  • unified format
选项:-U num 或 -u
输出格式:
--- from-file from-file-modification-time+++ to-file to-file-modification-time@@ from-file-range to-file-range @@ line-from-either-file line-from-either-file...
The lines common to both files begin with a space character. The lines that actually differ between the two files have one of the following indicator characters in the left print column:
+
    A line was added here to the first file.
-
    A line was removed here from the first file.
注意前面两种格式的输出都涉及到两个文件,而unified格式只涉及第一个文件,所以比较简洁。
                               
               
               
               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/83149/showart_1744207.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP