Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a diff tool I can run from the command line or maybe just an online webpage that will compare single lines? GitHub diffs do this but I'm don't want to publish things to GitHub just to read the diffs!

This is the sort of thing I'm wanting to diff:

a:2:{i:0;O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:8;s:5:"items";a:0:{}}s:5:"value";s:3:"bar";s:4:"next";N;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:15;s:5:"items";a:0:{}}s:5:"value";s:3:"zim";s:4:"next";r:8;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:22;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";r:15;s:4:"prev";r:8;s:6:"ofList";O:12:"FuLinkedList":1:{s:5:"items";a:4:{i:0;r:2;i:1;r:8;i:2;r:22;i:3;r:15;}}}s:6:"ofList";r:30;}s:6:"ofList";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:2:{i:0;r:2;i:1;r:8;}}}s:4:"prev";N;s:6:"ofList";r:37;}i:1;r:8;}
a:2:{i:0;O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";O:10:"FuTreeNode":6:{s:5:"outer";r:2;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:8;s:5:"items";a:0:{}}s:5:"value";s:3:"bar";s:4:"next";N;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:15;s:5:"items";a:0:{}}s:5:"value";s:3:"zim";s:4:"next";r:8;s:4:"prev";O:10:"FuTreeNode":6:{s:5:"outer";N;s:6:"inners";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:22;s:5:"items";a:0:{}}s:5:"value";s:3:"foo";s:4:"next";r:15;s:4:"prev";r:8;s:6:"ofList";O:12:"FuLinkedList":1:{s:5:"items";a:4:{i:0;r:2;i:1;r:8;i:2;r:22;i:3;r:15;}}}s:6:"ofList";r:30;}s:6:"ofList";O:20:"FuLinkedTreeNodeList":2:{s:5:"outer";r:2;s:5:"items";a:2:{i:0;r:2;i:1;r:8;}}}s:4:"prev";N;s:6:"ofList";r:37;}i:1;r:22;}

I'm on Mac OS X.

share|improve this question

migrated from stackoverflow.com Oct 14 '09 at 1:49

This question came from our site for professional and enthusiast programmers.

    
What operating system? –  silky Oct 14 '09 at 1:34

6 Answers 6

I use fold to wrap lines at a fixed width before using opendiff to diff them. It's hardly elegant, but it's really hard to find a line-line diff'er.

share|improve this answer
1  
nice because fold available on most platforms. In mac/bash: diff <(cat file1.sql | fold) <(cat file2.sql | fold) –  hobs Jan 11 '13 at 21:30
    
fold displays the text naturally so you can also do diff <(fold file1.sql) <(fold file2.sql). Try adding the -w 25 param to fold change the line length. –  Steve Tauber Jan 24 at 17:44
  1. You can break the line into 'words' (by say changing all ':' chars with a single whitespace). And then use wdiff which will do a word-diff forming words at the whitespaces.

  2. You could load the two files in KDiff3, it will highlight the difference (for long lines too).

share|improve this answer
    
brew install kdiff3 or similar for mac –  hobs Jan 11 '13 at 21:24

kompare will highlight the individual characters that differ.

Wikipedia has a fairly extensive comparison of diff-style tools here.

share|improve this answer

I just realized that FileMerge will highlight differences insides lines, although it doesn't seem to have an option to wrap long lines, which is annoying.

share|improve this answer

If you know vi or vim at all, I would suggest using vimdiff. Differences will be highlighted. Starts with a vertical split, you can use "vimdiff -o a.txt b.txt" for a horizontal split instead (might be better for a single line).

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.