2

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

f2.txt

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

f1.txt

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 
0

1 Answer 1

3

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-] 
4
  • sdiff also provides an alternative, showing differences side by side. Commented Oct 5, 2017 at 9:36
  • it's a great tool but I can't install anything on the server so I have to implement it manually Commented Oct 5, 2017 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? Commented Oct 6, 2017 at 14:10
  • @StéphaneChazelas it's not different. I have to write the algorithm of wdiff Commented Oct 9, 2017 at 12:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.