简体   繁体   English

在Linux中比较两个文件以匹配单词

[英]Comparing Two Files For Matching Words in Linux

Lets say we have two files as follows 可以说我们有两个文件,如下所示

File A.txt 文件A.txt

Karthick is not so intelligent He is not lazy 卡西克不是那么聪明,他也不是懒惰

File B.txt 文件B.txt

karthick is not so bad either He is hard worker karthick也不坏,他很努力

so in the two files above, the commone words are "karthick is not so" & "He is" in each of the lines. 因此,在上述两个文件中,每行的通用词分别为“ karthick并非如此”和“ He is”。 Is there any way to print all such common lines with either grep command or some linux command? 有没有办法用grep命令或某些linux命令打印所有这样的通用行?

You want to use the dwdiff utility :). 您要使用dwdiff实用程序:)。

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. 可能需要一些时间来适应它的输出,但是请查看http://linux.die.net/man/1/dwdiff以获得更多详细信息。

There are also several visual diff applications out there, but I prefer using it on the command line. 还有一些视觉差异应用程序,但是我更喜欢在命令行上使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM