如何比较两个文件中的特定值并提供差异? [英] How to compare particular values in two files and providing difference?

查看:62
本文介绍了如何比较两个文件中的特定值并提供差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





目前我已经完成了比较两个文本文件的代码(端到端)逐个读取所有行。



但是我想比较两个文本文件中的特定值,它必须提供差异结果。请参阅下面的示例。我需要结果如下例所示。





文件A:

------ -

abcdefghi

jklmn



10.1.1.1

10.1.1.2

10.1.1.3

10.1.1.4



档案B:

- -----



abcdefg



10.1.1.1

10.1 .1.2

10.1.1.3

***



差异结果

-----------------



文件A:

------ -



10.1.1.4



文件B:

--- ----



**



在上面的例子中。它只比较两个文件中的IP,并且提供差异结果等数据。同样的事情是必需的。它不应该与IP地址以外的其他地方进行比较。如果任何IP错过,或者这些IP中的任何不匹配。它必须提供差异。



请帮帮我。

Hi,

Currently i have done code for comparing two text files(End to end)Read all lines one by one.

But i want to compare only particular values in both the text files and it has to provide the difference result. Please see the example below. I need the result same like below example.


File A:
-------
abcdefghi
jklmn

10.1.1.1
10.1.1.2
10.1.1.3
10.1.1.4

File B:
-------

abcdefg

10.1.1.1
10.1.1.2
10.1.1.3
***

Difference result
-----------------

File A:
-------

10.1.1.4

File B:
-------

**

On the above example. It is comparing only the IPs in both the files and it is giving the data like difference result. Same thing is required. It should not compare other than IP address.If any IP missed out or any mismatch in those IPs alone. It has to provide the difference.

Please help me.

推荐答案



有人为我的查询提供解决方案吗?
Hi,
Anybody having solution for my query?


这篇关于如何比较两个文件中的特定值并提供差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆