Shell script to compare ,diff and remove betwen 2 files

Hi Friends Need your expertise.

Command to check the difference and compare 2 files and remove lines . example

File1 is master copy and File2 is a slave copy . whenever i change, add or delete a record in File1 it should update the same in slave copy . Can you guide me how can i accomplish this.

File1

1234
4567
8923

File2

1234
4567
8923
7879

.....
File2 has 7879 extra line and want to delete that line. and compare 2 files and it should be a same copy by checking wc -l File1 File2.

Thanks in advance

Perhaps I do not understand, but
if file2 is supposed to be the same as file1, why not

cp file1 file2
1 Like

Thanks friend sometimes simple things become complicated. You gave a good idea to solve the problem. appreciate it. I knew the answer but this answer gave me another idea...Joeyg

You can generate an ex script to modify the copy back in sync using diff -e. This can be good for sending small changes to a big file over slow networks.

Now, if you have a master file and 2 children with different changes, you can generate an ex script to put both changes in the master using diff3 -e Think parallel development changes merge.