无法使用 diff 确定差异
我有两个文件,我试图比较它们看起来完全相同,但是当我对它们运行 diff 时,我得到下面的输出...
在查看了这个文件一个小时的大部分时间后,我无法确定区别在于。我什至使用透明窗口应用程序比较了两个文件,看不出有什么不同。有什么想法吗?我错过了什么吗?谢谢
8c8
< 3 Molly Poultice / Ledasha Winnie 121.88 42.62
---
> 3 Molly Poultice / Ledasha Winnie 121.88 42.62
10c10
< 5 Charlie Anthony Fink / Xavier Together 121.33 42.42
---
> 5 Charlie Anthony Fink / Xavier Together 121.33 42.42
12,13c12,13
< 1 2 3 4 5 6 7 8 9 10 11 12 13
< - - - - - - - - - -- -- -- --
---
> 1 2 3 4 5 6 7 8 9 10 11 12 13
> - - - - - - - - - -- -- -- --
15,16c15,16
< Board 1 8.5 8.5 0 8.5 2 6 ---- 11 4 4 8.5 4 1
< 100 100 -500 100 -140 90 ---- 150 50 50 100 PASS -300
---
> Board 1 8.5 8.5 0 8.5 2 6 ---- 11 4 4 8.5 4 1
> 100 100 -500 100 -140 90 ---- 150 50 50 100 PASS -300
18,19c18,19
< Board 2 7.5 9.5 2 2 7.5 5 ---- 11 6 2 9.5 2 2
< 110 130 -140 -140 110 -110 ---- 140 100 -140 130 -140 -140
---
> Board 2 7.5 9.5 2 2 7.5 5 ---- 11 6 2 9.5 2 2
> 110 130 -140 -140 110 -110 ---- 140 100 -140 130 -140 -140
21,22c21,22
< Board 3 ---- 3.80 7.5 11 2.11 7.5 7.5 7.5 7.5 2.11 0 2.11 7.5
< ---- 80 110 140 -50 110 110 110 110 -50 -150 -50 110
---
> Board 3 ---- 3.80 7.5 11 2.11 7.5 7.5 7.5 7.5 2.11 0 2.11 7.5
> ---- 80 110 140 -50 110 110 110 110 -50 -150 -50 110
I have two files I'm trying to compare which appear to be exactly the same, yet when I run diff on them I get the output below...
After looking over this for the better part of an hour, I cannot determine what the difference is. I've even compared the two files one on top of the other using a transparent window app and can't see anything different. Any ideas? Am I missing something? Thanks
8c8
< 3 Molly Poultice / Ledasha Winnie 121.88 42.62
---
> 3 Molly Poultice / Ledasha Winnie 121.88 42.62
10c10
< 5 Charlie Anthony Fink / Xavier Together 121.33 42.42
---
> 5 Charlie Anthony Fink / Xavier Together 121.33 42.42
12,13c12,13
< 1 2 3 4 5 6 7 8 9 10 11 12 13
< - - - - - - - - - -- -- -- --
---
> 1 2 3 4 5 6 7 8 9 10 11 12 13
> - - - - - - - - - -- -- -- --
15,16c15,16
< Board 1 8.5 8.5 0 8.5 2 6 ---- 11 4 4 8.5 4 1
< 100 100 -500 100 -140 90 ---- 150 50 50 100 PASS -300
---
> Board 1 8.5 8.5 0 8.5 2 6 ---- 11 4 4 8.5 4 1
> 100 100 -500 100 -140 90 ---- 150 50 50 100 PASS -300
18,19c18,19
< Board 2 7.5 9.5 2 2 7.5 5 ---- 11 6 2 9.5 2 2
< 110 130 -140 -140 110 -110 ---- 140 100 -140 130 -140 -140
---
> Board 2 7.5 9.5 2 2 7.5 5 ---- 11 6 2 9.5 2 2
> 110 130 -140 -140 110 -110 ---- 140 100 -140 130 -140 -140
21,22c21,22
< Board 3 ---- 3.80 7.5 11 2.11 7.5 7.5 7.5 7.5 2.11 0 2.11 7.5
< ---- 80 110 140 -50 110 110 110 110 -50 -150 -50 110
---
> Board 3 ---- 3.80 7.5 11 2.11 7.5 7.5 7.5 7.5 2.11 0 2.11 7.5
> ---- 80 110 140 -50 110 110 110 110 -50 -150 -50 110
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
-b
选项添加到diff
以忽略空格中的更改并查看您的文件现在是否匹配。Add the
-b
option todiff
to ignore changes in whitespace and see if your files now match.此文本文件是否在类 UNIX 系统和 MacOS 或 Windows 之间移动?如果文件是在不同操作系统上编辑或写入的,则可能会出现行结尾差异。我会使用 od -x 来对每个文件的第一位进行十六进制转储,并查看其差异。
例如,第一个不同的行是 3 号,所以这样做
Was this text file moved between UNIX-like systems and MacOS or Windows? You may have line ending differences if the file was edited or written on different OSes. I would use
od -x
to do a hex dump of the first bit of each file and look at the diff of that.For instance, the first different line is number 3 so do
造成这种情况的一个可能原因是行结尾不同 - diff 将显示差异,其中一个文件具有以
\r\n
结尾的行(字节 0x10 0x13),而另一个文件具有以\n 结尾的行
(仅字节 0x13)。一个或另一个文件的行尾也可能有多余的空格,而另一个文件则没有。A likely reason for this is different line endings -- diff will show differences where one file has lines ending with
\r\n
(bytes 0x10 0x13), and another has lines ending with\n
(just byte 0x13). One or the other file might also have extra spaces on the end of the lines where the other doesn't.