How does "diff" only show differences?
Hi,
I am trying to compare two files with diff to see what the differences are between those two files. The problem I have with it is that the diff output shows both files instead off showing me the differences only. There are lines in the two files that are exactly the same but are shown in the output anyhow instead of leaving them away. The way I use diff is: Code:
diff filename filename Thanks. Ben |
It could be that there's an extra bit of whitespace (spaces) at the end of the line, et cetera. Playing with the options may be of help -- the following are from the man page:
-b Ignore changes in amount of white space. -B Ignore changes that just insert or delete blank lines. -i Ignore changes in case; consider upper- and lower-case letters equivalent. -I regexp Ignore changes that just insert or delete lines that match regexp. --ignore-all-space Ignore white space when comparing lines. |
Thanks for your help Poetics.
I have tried the different options (I have also combind them) you mention, except "-I", but they do not work. I have also checked the lines that correspond to each other, but there's no extra whitespace. They are exactly the same. If I put the corresponding lines from the two files into two new files, diff does not show differences though. I do not understand what the "-I" option does. Can you explain to me how I can apply this, and do your have other suggestions pherhaps? Ben |
Maybe you have an alias for diff. Try the following.
alias diff See if that clears things up. |
you could try gtkdiff. I've found it much easier to understand!
|
Quote:
|
Quote:
Other ideas on how to possibly solve this are still welcome of course. Thanks, Ben |
The lines diff are showing you are for context. The default is three lines before and after. If you use:
Code:
# diff -C0 file1 file2 Code:
# diff -C0 file1 file2 | grep -e "^\!" |
Great! I have got it working now.
Everyone thanks for your help :) Ben |
Quote:
I know now that the reason diff says the files differ is because the lines in the files are in a different order. Besides the order everything is equal. Does someone know with what command I can make the order of the lines equal? |
Quote:
|
Thanks bulliver. I will take a look at it.
Regards, Ben |
All times are GMT -5. The time now is 08:06 AM. |