I am using Emacs on a GNU/Linux system. I am trying to compare two data files containing columns of numbers which are almost similar in content. Is there an Emacs/Unix utility to highlight the differences between these text files?
cmp command in Linux/UNIX is used to compare the two files byte by byte and helps you to find out whether the two files are identical or not.
Using File Compare or the FC command in Command Prompt is another way if you need text or binary compare. The output is shown in Command Prompt and is not easy to read. For all file formats that Word can open, the Compare option in Word is the easiest to use. Windows 11 review: Is it better than Windows 10?
sdiff command in linux is used to compare two files and then writes the results to standard output in a side-by-side format. It displays each line of the two files with a series of spaces between them if the lines are identical.
In emacs, if you pull both files into different buffers, you can use the M-x ediff-buffers
command to display the differences. Emacs will nicely highlight the differences and allow you to scroll through the buffers concurrently. See tip #5 on this "Ten Essential Emacs tips" page, or the GNU docs on Ediff.
Under Unix there's the diff
command. Here's a short example of using diff, and one more example
I usually prefer comparing with Emacs, more visual, though of course both files will need to fit into buffers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With