如何获取差异以报告新行,更改行和已删除行的摘要 [英] How to get diff to report summary of new, changed and deleted lines

查看:58
本文介绍了如何获取差异以报告新行,更改行和已删除行的摘要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要两个文件之间的区别的摘要。预期输出是新行,已删除行和已更改行的计数。 diff是否容易提供这样的输出?如果没有,则可用任何脚本/实用程序来帮助获取摘要。

I want to have summary of difference between two files. Expected output is count of new, deleted and changed lines. Does diff readily provides such output? If not is there any script/utility available which helps in getting the summary.

推荐答案

如果使用diff -u,它将生成统一的diff,其行之前带有 + -。如果通过grep传递输出(仅获取 + -),然后传递给wc,则获取 + 的计数和分别是-

If you use diff -u it will generate a unified diff that has lines preceded with + and -. If you pipe that output through grep (to get only the + or -) and then to wc you get the counts for the + es and the - es respectively.

这篇关于如何获取差异以报告新行,更改行和已删除行的摘要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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