bash – unix diff side-to-side结果?

前端之家收集整理的这篇文章主要介绍了bash – unix diff side-to-side结果?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我如何绘制一个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

我想有一些像:

diff /tmp/test1  /tmp/test2
1,2
< asfdsadf       > asdfsafdsf
< asdfsad        > saf       
< fsaf
< fdsadf
---
6,14
< sadfa               > sadf
< fd              > sadf
---               > sadf
              > sadf
              > sadf
              > sadf
              > sadf
              > sadf
              > safa
从man diff,你可以使用-y做并排。
-y,--side-by-side
       output in two columns

因此,说:

diff -y /tmp/test1  /tmp/test2

测试

$ cat a                $ cat b
hello                  hello
my name                my name
is me                  is you

让我们来比较它们:

$ diff -y a b
hello                                                           hello
my name                                                         my name
is me                                                         | is you

猜你在找的Bash相关文章