diff3 命令
用途
比较三个文件。
语法
描述
diff3 命令比较三个文件,并将不同文本的范围写到标准输出,以下列代码为标志:
| 项 | 描述 |
|---|---|
| ==== | 三个文件都不同。 |
| == 1 | File1 不同。 |
| == 2 | File2 不同。 |
| == 3 | File3 不同。 |
需要用以将给定文件的指定范围转换以匹配另一文件的更改类型,在输出中由以下 2 种方式之一指明:
| 项 | 描述 |
|---|---|
| 文件:Number1 a | 文本添加到 File 中的行号 Number1 后,其中 File 可以是 1、2 或 3。 |
| 文件:Number1[,Number2]c | 第 Number1 行与第 Number2 行之间的文本将被更改。 如果 Number1 同 Number2 相等,范围减缩为第 Number1 行。 |
相应范围的内容在 c 指示之后。 当两文件内容相同时,命令 diff3 不显示较小编号文件的内容,虽然它显示相同行的位置。
注: 由 -e 标志生成的编辑脚本不能创建由 a 组成的行。 :NONE.
标志
示例
列举三个文件的不同处:
diff3 fruit.a fruit.b fruit.c如果fruit.a,fruit.b和fruit.c包含以下数据:
fruit.a fruit.b fruit.c
banana apple grape
grape banana grapefruit
kiwi grapefruit kiwi
lemon kiwi lemon
mango orange mango
orange peach orange
peach pear peach
pare然后 diff3 命令的输出显示了这些文件的差异,如下所示。 (右边的注释不会出现在输出中。)
==== All three files are different.
1:1,2c Lines 1 and 2 of the first file, fruit.a
banana
grape
2:1,3c Lines 1 through 3 of fruit.b
apple
banana
grapefruit
3:1,2c Lines 1 and 2 of fruit.c
grape
grapefruit
====2 The second file, fruit.b, is different.
1:4,5c Lines 4 and 5 the same in fruit.a and fruit.c.
2:4a To make fruit.b look same, add after line 4.
3:4,5c
lemon
mango
==== The first file, fruit.a, is different.
1:8c
pare
2:7c fruit.b line 7 and fruit.c line 8 are the same
pear
3:7a文件
| 项 | 描述 |
|---|---|
| /usr/bin/diff3 | 指示 diff3 命令。 |
| /usr/lbin/diff3prog | 被 diff3 shell 脚本调用。 |