命令行递归基于单词的差异?

发布于 2024-10-17 10:12:51 字数 262 浏览 9 评论 0原文

是否有一个命令行程序可以提供基于单词的递归差异(在两个目录上)?

diff -u 是递归的,但它不进行逐字比较。 wdiffdwdiff 进行基于单词的比较,但没有用于递归比较的内置选项。

我想将结果通过管道传递给 colordiff,因此生成 colordiff 可以理解的输出的程序将特别有用。有什么建议吗?谢谢!

抄送

is there a command line program that gives recursive word-based diff (on 2 directories)?

diff -u is recursive, but it doesn't do word by word comparison. wdiff and dwdiff does word based diff but there are not built-in options for recursive diff.

I would like to pipe the result to colordiff so a program that generates output that colordiff understands would be especially useful. Any suggestions? Thanks!

CC

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

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

发布评论

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

评论(1

岁月静好 2024-10-24 10:12:51

Git 可以做到这一点并输出颜色:

以下通常有效:

git diff --color-words path1 path2

但一般来说,您可能需要这样做

git diff --no-index --color-words path1 path2

两个文件甚至都不需要位于 git 存储库中!

如果您和路径位于 git 工作树中,则需要 --no-index 。如果您或其中一个文件位于 git 工作树之外,则可以将其删除。

联机帮助页: https://git-scm.com/docs/git-diff/1.8 .5(及之后...)

git diff --no-index [--options] [--] [...]

此形式用于比较文件系统上给定的两个路径。你可以
在工作树中运行命令时省略 --no-index 选项
由 Git 控制并且至少有一个路径指向外部
工作树,或者在工作树外部运行命令时
由Git控制。

Git can do it and output color:

The following often works:

git diff --color-words path1 path2

but in general you may need to do

git diff --no-index --color-words path1 path2

Neither file even needs to be in a git repository!

--no-index is needed if you and the paths are in a git working tree. It can be elided if you or one of the files are outside a git working tree.

Manpage: https://git-scm.com/docs/git-diff/1.8.5 (and later...)

git diff --no-index [--options] [--] […​]

This form is to compare the given two paths on the filesystem. You can
omit the --no-index option when running the command in a working tree
controlled by Git and at least one of the paths points outside the
working tree, or when running the command outside a working tree
controlled by Git.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文