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?

4
  • 7
    Maybe DOS text? Try doing dos2unix file1 and dos2unix file2 to delete possible bad characters. Commented Feb 15, 2014 at 17:50
  • Yes it was this case. thanks. Commented Feb 15, 2014 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. Commented Feb 15, 2014 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. Commented Oct 26, 2022 at 3:44

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.