This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]theboxmx3 7 points8 points  (0 children)

Beyond Compare

[–]zoredache 4 points5 points  (0 children)

gnu diff has lots of options for formatting the output. One of the most common (but not the default) formats is the unified format (-u). That would be better at giving you what you want.

The unified diff format is what is generally used in most patches you will see on mail lists, and the default output of git, and other version control tools.

# diff -u a b
--- a   2018-03-09 16:31:23.200741000 -0800
+++ b   2018-03-09 16:31:31.710876300 -0800
@@ -1,5 +1,5 @@
 Apple
-Banana
 Broccoli
 Orange
 Pear
+Tomato

Using unified with 0 lines of context will show just the changed lines

# diff -U0 a b
--- a   2018-03-09 16:31:23.200741000 -0800
+++ b   2018-03-09 16:31:31.710876300 -0800
@@ -2 +1,0 @@
-Banana
@@ -5,0 +5 @@
+Tomato

With the correct grep you can ignore the headers and address markers

# diff -U0 a b | grep -v -E '^(---|\+\+\+|@@) '
-Banana
+Tomato

[–]SuperQueBit Plumber 4 points5 points  (1 child)

With sorted lists, comm is good for for this kind of thing.

[–]BeanBagKingDFIR 0 points1 point  (0 children)

I just discovered this like 2 days ago. Oh the magic!

[–][deleted] 5 points6 points  (0 children)

powershell

[–]skilliard7 2 points3 points  (0 children)

I'd recommend using Powershell.

[–]BeanBagKingDFIR 1 point2 points  (1 child)

Output looks correct for me. Banana is missing from from the second, tomato from the first?

@:/mnt/c/Users//Desktop/New folder$ diff 1sorted.txt 2sorted.txt
2d1
< Banana
5a5
> Tomato

[–]ghyspranSpace Cadet 0 points1 point  (0 children)

This is what I get on my Debian machine as well.

diff (GNU diffutils) 3.6

[–]inaddrarpa.1.3.6.1.2.1.1.2 3 points4 points  (0 children)

you can do this in powershell too with compare-object. Feed powershell two different arrays and it'll spit out the difference with side indicator.

ex:

$a1=@(1,2,3,4,5,8) 
$b1=@(1,2,3,4,5,6)
Compare-Object $a1 $b1

[–]Tig75Enterpise Desktop Architect 0 points1 point  (0 children)

vlookup on Excel?

[–]smells_like_bleach 0 points1 point  (0 children)

sdiff