Chinaunix首页 | 论坛 | 博客
  • 博客访问: 87584
  • 博文数量: 15
  • 博客积分: 581
  • 博客等级: 中士
  • 技术积分: 185
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 15:29
文章分类
文章存档

2009年(10)

2008年(5)

我的朋友

分类: LINUX

2008-12-26 15:06:34


1. diff
%和空格有关的选项
  • -E:忽略因把制表符扩展为空格而造成的差异
  • -b:忽略因空白符的数目而造成的差异
  • -w:忽略所有空白符
  • -B:忽略空行(指连空白符都没有的行)
%忽略大小写: -i

%忽略所有差异都匹配正则表达式的行: -I regexp

%只列出哪些文件互不相同: -q

%输入格式
  • without context
change-command
< from-file-line
< from-file-line...
---
> 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格式只涉及第一个文件,所以比较简洁。




阅读(706) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-01-04 14:45:37

good