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 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

migration rejected from stackoverflow.com May 6 at 15:34

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by mdpc, Nifle, Frank Thomas, Kevin Panko, Raystafarian May 6 at 15:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking product, service, or learning material recommendations are off-topic because they become outdated quickly and attract opinion-based answers. Instead, describe your situation and the specific problem you're trying to solve. Share your research. Here are a few suggestions on how to properly ask this type of question." – mdpc, Nifle, Frank Thomas, Kevin Panko, Raystafarian
If this question can be reworded to fit the rules in the help center, please edit the question.

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

7 Answers 7

up vote 2 down vote accepted

diff_match_patch works in the browser.

share
    
Yay! This works. Thank you –  Ollie Saunders May 3 at 9:49

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
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 '14 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
    
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

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

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

I solved the problem with the linewrapping with https://www.diffchecker.com/ You can save the website locally and it still work. It shows you the differences (also in line) und wraps the lines.

share
    
Just tried this with the example data used in the initial post; didn’t work at all, just said the whole two lines were different. –  Ollie Saunders May 3 at 9:47

protected by Nifle May 4 at 16:12

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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