Diff command: does not print lines that are different, but still says that the two files are different from each other

I use the diff command to compare two text files. They must be literally consistent.

Therefore, I use diff:

diff binary.out binary.expected

(By the way, these files are not binary files, they are a text file, I call them binary, because this is the name of the project)

and received

Binary files binary.out and binary.expected differ

When I use another diff tool, the smartest of all (AKA human), and there is nothing else between the two files.

Does anyone know what is going on here?

Thanks.

+6
source share
2 answers

Be sure to ignore the space in the diff options.

It can also see Unicode characters and interpret it as binary. See if your diff tool has the ability to force text mode.

+2
source

diff from diffutils is talking about text / binar:

diff determines whether the file is text or binary by checking the first few bytes in the file; the exact number of bytes is a system, but usually a few thousand. If every byte in this part of the file is not zero, diff considers the file to be text; otherwise, it considers the file to be binary.

Therefore, GNU diff has a fairly open definition of what text is, and the use of the --text parameter to make it process the file, since text is rarely needed.

Is it checked if binary.out or binary.expected contains empty characters? What version is your diff program?

+5
source

Source: https://habr.com/ru/post/914089/


All Articles