Tagging the differencies in both files
- by Hakim
I know that comparing 2 files is a typical problem and there are many discussions on this problem. but I have a rather different problem while working with text files:
I have two text files which may differ in number of lines. now I want to compare two files and find the lines which differ. after that I want to tag all the differencies in both of files. for example here are the content of my files:
File1.txt:
This is the first line.
This line is just appeared in File1.txt.
you can see this line in both files.
this line is also appeared in both files.
this line and,
this one are mereged in File2.txt.
File2.txt:
This is the first line.
you can see this line in both files.
this line is also appeared in both files.
this line and, this one are mereged in File2.txt.
After processing I want both files to be like this:
File1.txt:
This is the first line.
<Diff>This line is just appeared in File1.txt.</Diff>
you can see this line in both files.
this line is also appeared in both files.
<Diff>this line and,</Diff>
<Diff>this one are merged in File2.txt.</Diff>
File1.txt:
This is the first line.
<Diff></Diff>
you can see this line in both files.
this line is also appeared in both files.
<Diff>this line and, this one are mereged in File2.txt.</Diff>
<Diff></Diff>
How can I do this? I know that some tools such as diff could help me, but how can I convert their results in this format?
Thank you in advance.