Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing Two Files For Matching Words in Linux

Lets say we have two files as follows

File A.txt

Karthick is not so intelligent He is not lazy

File B.txt

karthick is not so bad either He is hard worker

so in the two files above, the commone words are "karthick is not so" & "He is" in each of the lines. Is there any way to print all such common lines with either grep command or some linux command?

like image 714
Karthick Avatar asked Jan 08 '11 17:01

Karthick


1 Answers

You want to use the dwdiff utility :).

Example usage:

dwdiff "File A.txt" "File B.txt"

It might take a little while to get used to it's output, but check http://linux.die.net/man/1/dwdiff for more details on that.

There are also several visual diff applications out there, but I prefer using it on the command line.

like image 196
tomeduarte Avatar answered Sep 28 '22 23:09

tomeduarte