This question already has an answer here:

I Don't need a tool I need an implemetation/alghorithm :) I need to make a shellscript because I can't install anything on the server


She has 123 apples
George 18 years is old
Florin it's leaving
Michael it's not here
Peter is smiling


She has 132 apples
George is 18 years old
Michael it's not here
Peter is smiling
He is sleeping

Desired output:

diff is at:
line 1 : 123 instead of 132
line 2 : 18 years is instead of is 18 years
lines missing:
He is sleeping
lines added:
line 3: Florin it's leaving

marked as duplicate by αғsнιη, sebasth, Stephen Rauch, Archemar, Romeo Ninov Oct 5 '17 at 12:46

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Not exactly the format you're asking for, but wdiff is probably your best bet:

$ wdiff f1.txt f2.txt
She has [-132-] {+123+} apples
George [-is-] 18 years {+is+} old
{+Florin it's leaving+}
Michael it's not here
Peter is smiling
[-He is sleeping-]
  • sdiff also provides an alternative, showing differences side by side. – Raman Sailopal Oct 5 '17 at 9:36
  • it's a great tool but I can't install anything on the server so I have to implement it manually – Stoian George Oct 5 '17 at 10:16
  • @StoianGeorge, presumably, you'll still have to write a script for that. In what way is that different from copying a wdiff executable? – Stéphane Chazelas Oct 6 '17 at 14:10
  • @StéphaneChazelas it's not different. I have to write the algorithm of wdiff – Stoian George Oct 9 '17 at 12:02

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