- 论坛徽章:
- 0
|
Comparing and Merging Files
1. diff
%和空格有关的选项
- -E:忽略因把制表符扩展为空格而造成的差异
- -b:忽略因空白符的数目而造成的差异
- -w:忽略所有空白符
- -B:忽略空行(指连空白符都没有的行)
%忽略大小写: -i
%忽略所有差异都匹配正则表达式的行: -I regexp
%只列出哪些文件互不相同: -q
%输入格式
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)
选项:-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.
选项:-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 |
|