3

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?

Benjamin Bannier
  • 55,163
  • 11
  • 60
  • 80
mhm
  • 313
  • 1
  • 5
  • 12
  • 7
    Maybe DOS text? Try doing `dos2unix file1` and `dos2unix file2` to delete possible bad characters. – fedorqui Feb 15 '14 at 17:50
  • Yes it was this case. thanks. – mhm Feb 15 '14 at 18:04
  • 2
    You may also try `file original` and `file myfile`, to see if they are "the same kind". If they have different line endings, it will show in that they have different descriptions. – Mats Petersson Feb 15 '14 at 18:05
  • My case: I have 2 csv files which have same content. One is CRLF line ending, the other is LF line ending. View in hex e.g. `xxd`, `hexdump` or `hexyl` helps. – Rick Oct 26 '22 at 03:44

3 Answers3

7

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.

Prakhar Agarwal
  • 2,724
  • 28
  • 31
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
fedorqui
  • 275,237
  • 103
  • 548
  • 598
1

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

Gangnus
  • 24,044
  • 16
  • 90
  • 149