I have tried using the linux
diff command in the past without much luck or patience. I usually end up using a GUI utility like DiffMerge or Kdiff.
Recently I started trying to use
diff again to compare files on remote systems via ssh, and I have found the
-y / --side-by-side option to be very useful, but I still feel like I'm not making this most of this utility.
So I'm curious of how to achieve the following things:
- Highlight changes or use color-coding to make the output more readable
- Merge - Select lines with differences and effect the changes into one of the files
Also, I haven't found many good examples when googling, so if you have some linux-fu secrets for getting the most out of diff, could you please share? I will mainly be comparing text-based configuration files but any tricks and tips would be wonderful.
For Reference - The DiffMerge utility easily shows changes side by side with color highlighting. Icons at the top allow you to switch between views of "show all," "show differences," and "show differences with context." Would love some of this functionality at the command prompt.
ps: I should also note that one other option that I find quite useful is
--suppress-common-lines which I learned about on this concise and readable blog post.