且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取差异以报告新行,更改行和已删除行的摘要

更新时间:2023-12-04 21:28:46

如果使用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.