案例1:
先建立两个文件diff1.txt和diff2.txt:
[root@zcwyou ~]# cat diff1.txt
1a
2
3
4
[root@zcwyou ~]# cat diff2.txt
1
2b
3c
4
5
6
7
8
执行一下比较:
[root@zcwyou ~]# diff diff1.txt diff2.txt
输出结果如下:
1,3c1,3
< 1a
< 2
< 3
1
2b
3c
4a5,8
5
6
7
8
1,3c1,3表示有1行相当(第4行),3行c(c表示修改过,d表示删除,a表示增加),它们的行号范围是1-3。然后列出不同的地方。
4a5,8,表示有4行是增加的,行号是5-8。
案例2:
再建立两个文件:
文件1内容:cisco1.txt
enable
conf t
hostname ZS_121_201_122_120
no ip domain-lookup
vlan 1000
interface Vlan 1000
ip address 12.21.12.12 255.255.255.0
no sh
ip route 0.0.0.0 0.0.0.0 12.21.12.1
文件2内容:cisco2.txt
enable
conf t
hostname ZS_121_201_122_120
no ip domain-lookup
vlan 100
vlan 1000
interface Vlan 1000
ip address 12.21.12.12 255.255.255.0
ip route 0.0.0.0 0.0.0.0 12.21.12.13
执行比较:
[root@zcwyou ~]# diff cisco1.txt cisco2.txt -y -w -W 50
对比结果如下:
enable enable
conf t conf t
hostname ZS_121_201_1 hostname ZS_121_201_1
no ip domain-lookup no ip domain-lookup
> vlan 100
>
vlan 1000 vlan 1000
interface Vlan 1000 interface Vlan 1000
ip address 12.21.12. ip address 12.21.12.
no sh | ip route 0.0.0.0 0.0.
ip route 0.0.0.0 0.0. |
表示右比左多,<表示左比右多。|表示不同。
评论前必须登录!
注册