Alex Alex - 2 months ago 10
Linux Question

Manually merge two files using diff

I'd like to merge two files by doing the following:


  1. Output the diff of the two files into a temp file and

  2. Manually select the lines I want to copy/save.



The problem here is that
diff -u
only gives me a file lines of context, while I want to output the entire file in a unified format.

Is there any way diff can do this?

Answer

"I want to output the entire file in a unified format. Is there any way diff can do this?"

Yes.

diff -U 9999999 file1.txt file2.txt > diff.txt

This should work, provided your files are less than 10 million lines long.