bash unix diff 左右结果?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17195308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
unix diff side-to-side results?
提问by 719016
How can I plot the results of a unix diff command side-to-side instead of one difference after the other? See below for an example:
如何并排绘制 unix diff 命令的结果而不是一个接一个的差异?请参阅下面的示例:
diff /tmp/test1 /tmp/test2
1,4c1,2
< asfdsadf
< asdfsad
< fsaf
< fdsadf
---
> asdfsafdsf
> saf
6,8d3
< sadf
< asdf
< sadf
10d4
< fasd
12,13c6,14
< sadfa
< fd
---
> sadf
> sadf
> sadf
> sadf
> sadf
> sadf
> sadf
> sadf
> safa
I would like to have something like:
我想要一些类似的东西:
diff /tmp/test1 /tmp/test2
1,4c1,2
< asfdsadf > asdfsafdsf
< asdfsad > saf
< fsaf
< fdsadf
---
6,8d3
< sadf
< asdf
< sadf
10d4
< fasd
12,13c6,14
< sadfa > sadf
< fd > sadf
--- > sadf
> sadf
> sadf
> sadf
> sadf
> sadf
> safa
回答by fedorqui 'SO stop harming'
From man diff
, you can use -y
to do side-by-side.
从man diff
,您可以使用-y
并排操作。
-y, --side-by-side
output in two columns
Hence, say:
因此,说:
diff -y /tmp/test1 /tmp/test2
Test
测试
$ cat a $ cat b
hello hello
my name my name
is me is you
Let's compare them:
让我们比较一下:
$ diff -y a b
hello hello
my name my name
is me | is you
回答by timmfin
From icdiff's homepage:
从icdiff的主页:
Your terminal can display color, but most diff tools don't make good use of it. By highlighting changes, icdiff can show you the differences between similar files without getting in the way. This is especially helpful for identifying and understanding small changes within existing lines.
Instead of trying to be a diff replacement for all circumstances, the goal of icdiff is to be a tool you can reach for to get a better picture of what changed when it's not immediately obvious from diff.
您的终端可以显示颜色,但大多数差异工具并没有很好地利用它。通过突出显示更改,icdiff 可以向您显示相似文件之间的差异而不会妨碍您。这对于识别和理解现有生产线中的微小变化特别有用。
icdiff 的目标不是试图成为所有情况下的 diff 替代品,而是成为一个工具,您可以使用它来更好地了解在 diff 中发生的变化不是很明显。
IMHO, its output is much more readable than diff -y
.
恕我直言,它的输出比diff -y
.
回答by Rjazhenka
diff -y --suppress-common-lines file1 file2
回答by srpatch
You can use:
您可以使用:
sdiff file1 file2
or
或者
diff -y file1 file2
or
或者
vimdiff file1 file2
for side by side display.
用于并排显示。
回答by Chris Seymour
You should have sdiff
for side-by-side merge of file differences. Take a read of man sdiff
for the full story.
您应该sdiff
并行合并文件差异。阅读man sdiff
全文。
回答by Jorge Fernando Matricali
You can simply use:
您可以简单地使用:
diff -y fileA.txt fileB.txt | colordiff
It shows the output splitted in two colums and colorized! (colordiff
)
它显示了分成两列并着色的输出!( colordiff
)
回答by ymattw
回答by rectummelancolique
Use the -y
option:
使用-y
选项:
diff -y file1 file2
回答by Eduardo Cuomo
You can use vimdiff
.
您可以使用vimdiff
.
Example:
例子:
vimdiff file1 file2
回答by Bucket
If your files have inconsistent use of spaces and tabs, you may find it helpful to include the -t
argument to expand the tabs:
如果您的文件对空格和制表符的使用不一致,您可能会发现包含-t
扩展制表符的参数很有帮助:
diff -ty file1 file2