Reputation: 3743
I am familiar with tools such as tkDiff and WinMerge and am aware of how to see the difference between two files.
What I'm looking to do is to produce a report of elements in one file that are not present in another.
For example:
File1 contains:
apple
cool
dude
flan
File2 contains:
apple
ball
cool
dude
elephant
I want to produce a report that contains:
ball
elephant
Or, better yet, a report like this:
+ball
+elephant
-flan
Does anybody know of a tool that can do this? Preferably with command line options.
The report feature in WinMerge isn't too far off what I'd like but there is no command line option to do this (as far as I know).
Thanks in advance.
Upvotes: 29
Views: 50518
Reputation: 41779
You probably want the Unix comm utility. Windows versions are included in gnuwin32
NAME
comm - compare two sorted files line by line
SYNOPSIS
comm [OPTION]... FILE1 FILE2
DESCRIPTION
Compare sorted files FILE1 and FILE2 line by line. With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files. -1 suppress lines unique to FILE1 -2 suppress lines unique to FILE2 -3 suppress lines that appear in both files
Upvotes: 26
Reputation: 1
To compare data with command prompt you can use
COMP /a /l D:\Folder1\data.txt D:\Folder2\data.txt
Here are other options to compare files and folders with command prompt.
Upvotes: -4
Reputation: 58578
This might work for you (GNU diff):
diff -u file1 file2 | sed -n '1,2d;/^[-+]/p'
+ball
-flan
+elephant
Upvotes: 47