wdiff突出显示差异

发布于 2025-02-10 06:31:37 字数 477 浏览 1 评论 0原文

如何使用WDIFF显示两个文件之间的单词差异?现在,我可以显示两个文件之间有哪些单词并打印出统计数据。我想确切地染色哪些单词不同。

#! usr/bin/bash
wdiff -si12 exp3.txt out.txt | colordiff

输出:

Input an integer greater than or equal to 0 or -1 to quit: 
The largest number is 5
Goodbye!
exp3.txt: 6 words  39 100% common  0 0% deleted  0 0% changed
out.txt: 6 words  39 100% common  0 0% inserted  0 0% changed

它打印所有常用单词。我已经做到了 - 固定是要查看受支持的WDIFF命令,但我找不到如何突出显示差异。任何帮助都将受到赞赏!

How do I use wdiff to show the word differences between two files? Right now, I can show which words are in common between two files and print out the stats. I'd like to color red exactly which words are different.

#! usr/bin/bash
wdiff -si12 exp3.txt out.txt | colordiff

This outputs:

Input an integer greater than or equal to 0 or -1 to quit: 
The largest number is 5
Goodbye!
exp3.txt: 6 words  39 100% common  0 0% deleted  0 0% changed
out.txt: 6 words  39 100% common  0 0% inserted  0 0% changed

It prints all the common words. I've done --help to look at the supported wdiff commands but I couldn't find how to highlight differences. Any help is appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江南烟雨〆相思醉 2025-02-17 06:31:37

WDIFF 手动页面建议一页添加颜色diffs的方法:

$ cat file1
Hello world, how are you today?
$ cat file2
Hello universe, how are you today?
$ wdiff -n -w 
\033[30;41m' -x 
\033[0m' -y 
\033[30;42m' -z 
\033[0m'  file1 file2

The final example on the wdiff manual page suggests a way to add color to the word diffs:

$ cat file1
Hello world, how are you today?
$ cat file2
Hello universe, how are you today?
$ wdiff -n -w 
\033[30;41m' -x 
\033[0m' -y 
\033[30;42m' -z 
\033[0m'  file1 file2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文