Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Two Files

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
I need to compare two files and get what are lines got modified from file1 to file2 and and what are lines got deleted from file1 to file2 and what are lines get newly added from file1 to file2 . Something like three files


First file will have ..Lines that got changed

Second file will have ..Lines got deleted

Third file will have ..lines got newly added.

Is there a tool avaliable to do this ...i tried diff command ...output is something like this


diff file1 file2



1c1
< 23|Test|Check
---
> 23|Test23|Check
3,4c3
< 25|Tester|Checker
< 26|asdf|qwer
---
> 26|asdf|qwered
5a5
> 28|Addeed|newadd


i understand 'c' means compare and 'a' means newly added
now i don't know how to extract as three files any help will be appreciated



 
No need to complicate things unnecessarily.

Code:
diff file1 file2 > files.diff

You can then use it as a patch.



--
Andy
&quot;Historically speaking, the presence of wheels in Unix has never precluded their reinvention.&quot;
Larry Wall
 
Thanks Andy ..Could you advise me how i can patch it ...is there an option in diff command for patching or i need to write a script.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top