In yesterday’s post, we learned how to find the discrepancies between two similar files using a command called diff. With it, we were able to compare them and identify the actual lines containing differences.
Once you have identified the differences between the two, you have a couple of options. If only one file is different, you can delete it, but if both files have slight differences and you need the changes from both, you will need to include the changes from both. That would normally involve creating a third file or revision containing both changes.
With the command sdiff you can display the file differences side-by-side and can also merge the two file changes into a third output file. To run sdiff, use the following command string:
sdiff -o outfile file1.txt file2.txt
It will display the two differences (see the image above). Press Enter, and it will then provide you with options. Choose the one you want and then Quit.