How can I plot the results of a unix diff command side-to-side instead of one difference after the other? See below for an example:
diff /tmp/test1 /tmp/test2 1,4c1,2 < asfdsadf < asdfsad < fsaf < fdsadf --- > asdfsafdsf > saf 6,8d3 < sadf < asdf < sadf 10d4 < fasd 12,13c6,14 < sadfa < fd --- > sadf > sadf > sadf > sadf > sadf > sadf > sadf > sadf > safa
I would like to have something like:
diff /tmp/test1 /tmp/test2 1,4c1,2 < asfdsadf > asdfsafdsf < asdfsad > saf < fsaf < fdsadf --- 6,8d3 < sadf < asdf < sadf 10d4 < fasd 12,13c6,14 < sadfa > sadf < fd > sadf --- > sadf > sadf > sadf > sadf > sadf > sadf > safa
If you want to compare two files, and display the differences, you can use the diff , the sdiff or vimdiff command. The diff will display the differences between two files. While the sdiff command will display the differences with file1 on the left and file2 on the right.
On Unix-like operating systems, the diff command analyzes two files and prints the lines that are different. In essence, it outputs a set of instructions for how to change one file to make it identical to the second file.
From man diff
, you can use -y
to do side-by-side.
-y, --side-by-side output in two columns
Hence, say:
diff -y /tmp/test1 /tmp/test2
$ cat a $ cat b hello hello my name my name is me is you
Let's compare them:
$ diff -y a b hello hello my name my name is me | is you
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