对显示的字符数使用diff和-y限制

时间:2015-01-29 22:29:45

标签: bash diff

我有这两个文件file1.txt:

$ cat file1.txt
I need to buy apples. I need to buy apples. I need to buy apples. I need to buy apples. I need to buy apples.
I need to run the laundry.
I need to wash the dog.
I need to get the car detailed.

和file2.txt:

$ cat file2.txt
I need to buy apples.
I need to do the laundry.
I need to wash the car.
I need to get the dog detailed.

我希望使用diff命令查看文件中的差异,并使用-y选项显示它。

$ diff -y file1.txt file2.txt
I need to buy apples. I need to buy apples. I need to buy app | I need to buy apples.
I need to run the laundry.                                    | I need to do the laundry.
I need to wash the dog.                                       | I need to wash the car.
I need to get the car detailed.                               | I need to get the dog detailed.

但似乎可以显示的字符数有限制。注意来自file1.txt的第1行。

是否可以增加此限制以显示全行内容?

$ echo I need to buy apples. I need to buy apples. I need to buy app | wc
      1      15      62

1 个答案:

答案 0 :(得分:1)

看起来你需要指定宽度,试试这个:

diff --width=250 -y file1 file2

man diff:

  

-W NUM --width = NUM                 输出最多NUM(默认为130)打印列。