[CLUE-Tech] Merge tool for combining files

robert anselmi ranselmi at americanisp.net
Mon Mar 24 22:01:19 MST 2003


On Monday 24 March 2003 09:29 am, you wrote:
> Does anybody know of an easy to use Linux merge tool
> that allows you to merge two files together? Typically
> these types of tools are used to combine two slightly
> different files into a new file, and they allow you to
> select the differences you want through an interface.
>


I have used sdiff which is on my Sarge distribution of Debian.  It outputs 
the files in two columns, side by side, separated by spaces. Lines that 
differ in the files are separated by a '|'; lines that appear only in the 
first file end with a '<', and lines that appear only in the second file are 
preceded with a '>'.
 
Before comparing the two files I go in with vi and at the command prompt I do 
a :set tw=30 and at each paragraph gq} makes the file skinny so that when the 
two files are side by side they don't go off the right end of the screen. (Of 
course after the first gq} the subsequent paragraphs can be skinnied up by 
typing the period '.' so the rest of the paragraphs go fast. or at the top of 
the file gqG skinnies all the paragraphs in the whole file.) The command I 
use is $sdiff file1.txt file2.txt | less You can also compare three files with
$diff3 file1.txt file2.txt file3.txt > file4.txt With a vi file4.txt you can 
see the differences in the three files.

You can also do $diff file1.txt file2.txt > file.diff    Then if you do a
$patch file1.txt file.diff it updates the file1.txt to look like file2.txt

This is particularly useful if you want to update a file across the network. 
It is faster to send a small patch file than a large source file.

Bob



More information about the clue-tech mailing list