linux下的文件对比工具下载,Linux文件对比工具—comm/egrep/diff

1、comm

带参数:

-1 不显示只在第1个文件里出现过的行。

-2 不显示只在第2个文件里出现过的行。

-3 不显示同时在第1和第2个文件里出现过的行。

comm对比的两个文件,要求先通过sort排序。不加参数时分“三列”显示,第一列是只存在于“第一个”文件中的内容,第二列是只存在于“第二个”文件中的内容,第三列是两个文件相同部分。

root@master # cat file1

a

b

c

root@master # cat file2

a

c

d

root@master # comm -12 file1 file2

a

c

2、egrep

egrep -f file1 file2 相当于 comm -12 file1 file2文件相同部分

root@master # egrep -f file1 file2

a

c

egrep -f file2 -v file1 相当于 comm -23 file1 file2 得到只存在于第一个文件中的部分

root@master # egrep -f file2 -v file1

b

egrep -f file1 -v file2 相当于 comm -13 file1 file2 得到只存在于第二个文件中的部分

root@master # egrep -f file1 -v file2

d

3、diff

diff可以比较两个文件,或者文件夹,着重于两个文件的相同部分和不同部分的统计。

diff -y file1 file2 | egrep -v '||' | awk '{print $1}'得到两个文件相同部分

root@master # diff -y file1 file2|egrep -v '|\|'|awk '{print $1}'

a

c

diff file1 file2 |grep '

root@master # diff file1 file2 |grep '

b

diff file1 file2 |grep '>'|awk '{print $2}'得到只存于第二个文件

root@master # diff file1 file2 |grep '>'|awk '{print $2}'

d

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值