【问题标题】:How to count the number of character differences between two files?如何计算两个文件之间的字符差异数?
【发布时间】:2020-04-03 17:58:35
【问题描述】:

Linux命令行下如何统计两个文件的字符差异个数?

【问题讨论】:

  • 你需要这个做什么?
  • 只需要数一数...

标签: linux diff git-diff


【解决方案1】:

可以使用git diffpcre2grep(Linux 上pcre2-utils 的一部分)来完成

git diff --patience --word-diff=porcelain --word-diff-regex=. file1 file2 | pcre2grep -M "^@[\s\S]*" | pcre2grep -M --file-offsets "(^-.*\n)(^\+.*\n)?|(^\+.*\n)" | wc -l

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    • 1970-01-01
    • 1970-01-01
    • 2010-10-29
    相关资源
    最近更新 更多