Home / Linux / Comparing files and directories with the diff and comm Linux commands

Comparing files and directories with the diff and comm Linux commands

There are a number of ways to compare files and directories on Linux systems. The diff, colordiff, and wdiff commands are just a sampling of commands that you’re likely to run into. Another is comm. The command (think “common”) lets you compare files in side-by-side columns the contents of individual files.

Where diff gives you a display like this showing the lines that are different and the location of the differences, comm offers some different options with a focus on common content. Let’s look at the default output and then some other features.

Here’s some diff output — displaying the lines that are different in the two files and using < and > signs to indicate which file each line came from.

$ diff whoison whoison-again
7c7
< who | awk '{print $1}' | sort | uniq
---
> who | awk '{print $1}' | sort | wc -l

If you’ve used the diff command a lot, you probably know that it can also display file content side by side. In the example below, we see that the one line that is different between the two files is marked with a vertical bar preceding the line that is different.

Loading...

>> Source Link

Check Also

Sensors, BLE, JavaScript and lots of nerd

The RuuviTag is a microcontroller-based sensor node which can measure temperature, relative air humidity, air …

%d bloggers like this: