h@kim has asked for the wisdom of the Perl Monks concerning the following question:
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>
File2.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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tagging the differencies in both files
by roboticus (Chancellor) on Jun 17, 2012 at 13:19 UTC | |
|
Re: Tagging the differencies in both files
by zentara (Cardinal) on Jun 17, 2012 at 13:52 UTC | |
by CountZero (Bishop) on Jun 17, 2012 at 16:52 UTC | |
by zentara (Cardinal) on Jun 17, 2012 at 19:42 UTC | |
by h@kim (Initiate) on Jun 18, 2012 at 05:54 UTC |