Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have two log files with thousands of lines. After pre-processing, only some lines differ. These remaining lines are either real differences, or shuffled groups of lines.

Unified diffs allow me to see the detailed differences, but it makes manual comparison with eye balls hard. Side-by-side diffs seems more useful for comparison, but it also adds thousands of unchanged files. Is there a way to get advantage of both worlds?

Note, these log files are generated by xscope which is a program that monitors Xorg protocol data. I am looking for general-purpose tools that can be applied to situation similar to the above, not specialized webserver access log analysis tools for example.


Two example log files are available at http://lekensteyn.nl/files/qemu-sdl-debug/ (log13 and log14). A pre-processor command can be found in the xscope-filter file which removes timestamps and other minor details.

share|improve this question
1  
Does your diff have --suppress-common-lines option? pastebin.com/KZrVCNFR –  manatwork Jun 12 '13 at 10:46
    
@manatwork Nice, it does. Any way to add more context (e.g. line numbers)? –  Lekensteyn Jun 12 '13 at 10:50
3  
Then maybe vimdiff (from the vim package) would serve your needs better: parallel display, colorized, common lines folded. Line numbers can be turned on with :set number. –  manatwork Jun 12 '13 at 11:07
    
I think you should put vimdiff up as an answer :) –  Kotte Jun 12 '13 at 14:03
    
Are GUI tools in the running? I love KDE's kompare for this purpose. –  depquid Jun 12 '13 at 14:18

2 Answers 2

The 2 diff tools I use the most would be meld and sdiff.

meld

Meld is a GUI but does a great job in showing diffs between files. It's geared more for software development with features such as the ability to move changes from one side to the other to merge changes but can be used as just a straight side-by-side diffing tool.

    ss of meld

    ss of meld code highlighting

sdiff

I've used this tool for years. I generally run it with the following switches:

$ sdiff -bBWs file1 file2
  • -b Ignore changes in the amount of white space.
  • -W Ignore all white space.
  • -B Ignore changes whose lines are all blank.
  • -s Do not output common lines.

Often with log files you'll need to make the width of the columns wider, you can use -w <num> to make the screen wider.

other tools that I use off and on

diffc

Diffc is a python script which colorizes unified diff output.

$ diffc [OPTION] FILE1 FILE2

             ss of diffc

vimdiff

Vimdiff is probably as good if not better than meld and it can be run from a terminal. I always forget to use it though which, to me, is a good indicator that I find the tool just a little to tough to use day to day. But YMMV.

                                    ss of vimdiff

share|improve this answer
    
One great feature of Meld, unfortunately not visible on your screenshot, is syntax highlighting of source code files. –  manatwork Jun 12 '13 at 14:35
    
Yes. I used to use vimdiff all the time, I've since moved to using meld, I find it easier to use and it's just easier to see what it's telling me vs. vimdiff. –  slm Jun 12 '13 at 14:42
    
@manatwork - added your link to the answer, thanks for the feedback! –  slm Jun 12 '13 at 14:51
    
Looks great for source code, but not so much for comparing log files. I often use colordiff from colordiff.org for source file. To my understanding, sdiff is similar to diff -y with no differences in output but slightly different options. +1 for showing some good alternatives to plain diff. –  Lekensteyn Jun 12 '13 at 15:45
    
I've not ever used colordiff, I'll have to check it out. You're correct on the diff -y. The addition of that switch to diff seems to have happened at some point, or I never noticed it. Additionally here's a link to the gnu diff tools resource page. Good stuff for using this suite of tools. –  slm Jun 12 '13 at 16:15

Currently I am using side-by-side diff with grep filtering the different lines:

diff -y -W250 log.txt log2.txt | expand | \
    grep -E -C3 '^.{123} [|<>]( |$)' | colordiff | less -rS
  • Option -W250 makes the output wider such that I can see more data.
  • expand is necessary to convert tabs to spaces
  • -C3 adds 3 lines of context to the grep output.
  • ^.{123} matches half of the data before the side-by-side diff markers.
  • colordiff makes the output prettier to follow
  • less -rS allows ANSI colors to be interpreted (-r) and prevents wrapped lines (-S).

This is a hack, alternatives are welcome.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.