How to get difference ratio using “diff” or other command

diff()

I have two files with thousands lines. I want to get their differences ratio in lines/bytes using diff, vimdiff or other commands, even regardless of the specific differences.

Best Answer

There's a tool called diffstat that sounds like what you're looking for.

$ diff <file1> <file2> | diffstat

Example

$ diff afpuri.c afpuri1.c | diffstat
 unknown |   53 ++++++++++++++++++++---------------------------------
 1 file changed, 20 insertions(+), 33 deletions(-)

This can be used for diff output which includes multiple files in a tree as well.

References

Related Question