Contents
Why does diff say two files are the same?
I have two files which look identical to me (including trailing whitespaces and newlines) but diff still says they differ. Even when I do a diff -y side by side comparison the lines look exactly the same. The output from diff is the whole 2 files. Any idea what’s causing it?
How to find common lines in two files?
Just sorting both files and using comm is not enough, because in that case the line information is lost. How about using diff, even though you don’t want a diff? Try this: -F means match plain strings (not regexps), -x means only whole-line matches, -f means take ‘patterns’ (i.e. lines) from the file named as its argument
How are changed lines separated in a file?
Changed lines are separated by | character. If a line exists only in file A, < is used as the separator character. If a line exists only in file B, > is used as the separator.
How to show similarities between two text files?
Diff is a great tool to display the changes between two files. But how to display the similarities of two text files (while ignoring the differences)? Just sorting both files and using comm is not enough, because in that case the line information is lost. How about using diff, even though you don’t want a diff?
How can I get a side by side diff?
You can do a side-by-side diff using sdiff as follows: $ git difftool -y -x sdiff HEAD^ | less where HEAD^ is an example that you should replace with whatever you want to diff against. I found this solution here where there are a couple of other suggestions also.
How to compare two files side by side?
The original question is explicitly about side-by-side comparison. Even files produced with cp will be completely listed in side-by-side mode – all problems with line feed, spaces or special characters aside. You will always need –suppress-common-lines to get the desired result.
Is there an external diff tool for Git?
For newer versions of git, the difftool command supports many external diff tools out-of-the-box. For example vimdiff is auto supported and can be opened from the command line by: Other supported external diff tools are listed via git difftool –tool-help here is an example output: You can also try git diff –word-diff .