Question

Original file contains:

B
RBWBW
RWRWWRBWWWBRBWRWWBWWB

My file contains :

B
RBWBW
RWRWWRBWWWBRBWRWWBWWB

However when i use the command diff original myfile it shows following:

1,3c1,3
< B
< RBWBW
< RWRWWRBWWWBRBWRWWBWWB
---
> B
> RBWBW
> RWRWWRBWWWBRBWRWWBWWB

When i put -w tag (diff original myfile -w) it shows no differences... but I'm absolutely sure these two files do not have whitespace/endline differences. What's the problem?

Was it helpful?

Solution 2

As seen in the comments, you must have some different line endings, caused because of an original file coming from a DOS system. That's why using -w dropped the end of the line and files matched.

To repair the file, execute:

dos2unix file

OTHER TIPS

These texts are equal.

Maybe you have extra white spaces.

try

diff -w -B file1.txt file2.txt

-w Ignore all white space.

-B Ignore changes whose lines are all blank.

Look at them in Hex format. This way you can really see if they are the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top