1

My question is if there is a tool in linux to find the difference in two files with lines so big as 39604 chars.

I tried with vimdiff, kompare, diff, colordiff, wdiff and other tools and none of them show me the exact difference.

All of them show the line, but is too long that is very hard to check which char is different and only after I found the position I can see it in vimdiff, that shows the difference (was a space at end). But I didn't find it because is very hard to go through all line.

But I would like to know if there is a faster way to compare this case or similar.

Thanks in advance.

oml
  • 115
  • 2
  • 8

1 Answers1

0

At end I found the difference loading two files with gedit, advancing both page per page and check if there are differences. Because I didn't find any difference I checked if the last char was a space and that was the difference and I got it!.

Surfing I found a good solution at https://unix.stackexchange.com/questions/45711/diff-reports-two-files-differ-although-they-are-the-same

"What if you hexdump them? This might show differences more obviously, eg:"

hexdump -C file1 > file1.hex
hexdump -C file2 > file2.hex
diff file1.hex file2.hex
oml
  • 115
  • 2
  • 8
  • Food for thought, how about breaking the line each 'n' chars and use a regular diff to spot the differences? Breaking lines idea: https://stackoverflow.com/questions/1187078/how-to-insert-a-new-line-character-after-a-fixed-number-of-characters-in-a-file – Rafa May 05 '20 at 13:31
  • You could also use `tr` to turn all spaces, or any other delimiter character, into newline characters, and then run a `diff`. Should yield better results on insertions/deletions than the `hexdump` approach: If you have a single character missing early in one file, the `hexdump` approach will basically flag everything following the missing character as different, with the delimiter translation, you get only the one word highlighted where the difference is located. – cmaster - reinstate monica May 05 '20 at 14:45
  • @cmaster-reinstatemonica This is a very good solution. Very thanks! – oml May 06 '20 at 07:08