LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2265|回复: 6

求助用perl 比较2个文本的内容,并将不同的地方写入1.TXT

[复制链接]
发表于 2008-3-31 16:45:35 | 显示全部楼层 |阅读模式
1.txt
servers sorted by max messages
ip_src                    tmsg          tjoin        tping     tpong     tprivmsg    maxchans     maxworm
***.***.***.*** 18432         731         433       33          17235        6                   0
***.***.***.*** 17650         699         410       33          16508        6                   16
***.***.***.*** 2697           142         38         24          2097          3                   57
***.***.***.*** 1155           147         0           592        416            1                   20
***.***.***.*** 940              73           236      0             631           3                   50
hosts with join msgs but no privmsgs
ip_src                    tmsg          tjoin        tping     tpong     tprivmsg    maxchans     maxworm
***.***.***.*** 18432         731         433       33          17235        6                   0
***.***.***.*** 17650         699         410       33          16508        6                   16
***.***.***.*** 2697           142         38         24          2097          3                   57
***.***.***.*** 1155           147         0           592        416            1                   20
***.***.***.*** 940              73           236      0             631           3                   50
2.txt
servers sorted by max messages
ip_src tmsg tjoin tping tpong tprivmsg maxchans maxworm
***.***.***.*** 18432 731 433 33 17235 6 0
***.***.***.*** 17650 699 410 33 16508 6 16
***.***.***.*** 2697 142 38 2420 97 3 57
***.***.***.*** 1155 147 0 592 416 1 20
***.***.***.*** 940 73 236 0 631 3 50
hosts with join msgs but no privmsgs
ip_src tmsg tjoin tping tpong tprivmsg maxchans maxworm
***.***.***.*** 18432 731 433 33 17235 6 0
***.***.***.*** 17650 699 410 33 16508 6 16
***.***.***.*** 2697 142 38 2420 97 3 57
***.***.***.*** 1155 147 0 592 416 1 20
***.***.***.*** 940 73 236 0 631 3 50

比较1.txt,,2.txt 的 IP_src地址的区别.
如果2.txt比1.txt增加的ip_src信息写入1.txt
求教一下如何写.

thx

***.***.***.***  比较IP
发表于 2008-3-31 17:25:14 | 显示全部楼层
直接用diff好了
如果不爽的话用tkdiff
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-3-31 20:32:26 | 显示全部楼层
能不能有不用diff的程序呢@@
回复 支持 反对

使用道具 举报

发表于 2008-4-1 08:39:57 | 显示全部楼层
Post by mikezhangsky;1833277
能不能有不用diff的程序呢@@


meld            你看看是否适合
回复 支持 反对

使用道具 举报

发表于 2008-4-28 18:37:10 | 显示全部楼层
用 perl 做起来很简单
回复 支持 反对

使用道具 举报

发表于 2008-4-28 19:51:08 | 显示全部楼层
还是 diff 爽一些,个人意见。
回复 支持 反对

使用道具 举报

发表于 2008-6-26 13:10:56 | 显示全部楼层
题目很不明确啊,到底是不同还是增加,减少的如何处理?

但是无论如何都很简单。给个思路:用散列,以ip为键名
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表