# linux diff对比文件

diff 是 Unix 系统的一个命令，用来比较两个文本文件的差异。一般用法：

\$diff file1 file2


diff 有三种输出格式

• 正常格式（normal diff）
• 上下文格式（context diff）
• 合并格式（unified diff）

git diff 输出的格式是最后一种。

[En]

The second line represents the hash values of the two versions of git, and the last six digits are the mode of the object (normal file, 644 permissions).

“—”表示变动前的文件，”+++” 表示变动后的文件。

[En]

The position of the change begins and ends with two @.

[En]

The preceding “- 4jue 6” is divided into three parts: the minus sign for the first file, “4” for line 4, and “6” for six consecutive lines. Taken together, it means that the following are six consecutive lines of the first file starting at line 4. Similarly, “+ 4re7” means that after the change, it becomes the second file with seven consecutive lines starting at line 4.

[En]

It displays the context of the two files together, so it is called “merge format”. The first flag bit of each line, empty indicates no change, the minus sign indicates the line deleted by the first file, and the plus sign indicates the new line added to the second file.

[En]

Common parameters

” -b ” 忽略空格
” -B ” 忽略空行
” -i ” 忽略大小写
” -c ” 显示文件所有内容并标示不同
” -r ” 对比目录
” -u ” 合并输出

[En]

Output result interpretation

diff 比较结果的含义，diff 描述两个文件不同的方式是告诉我们怎么样改变第一个文件之后与第二个文件匹配。
c = change
d = delete

[En]

The middle-is the delimited symbol of the contents of the two files.

[En]

Original: https://www.cnblogs.com/youxin/p/16389088.html
Author: youxin
Title: linux diff对比文件

(0)